ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - inancgumus/myhttp: Simplest HTTP GET requester for Go with timeout support
Simplest HTTP GET requester for Go with timeout support - inancgumus/myhttp
Visit Site

GitHub - inancgumus/myhttp: Simplest HTTP GET requester for Go with timeout support

GitHub - inancgumus/myhttp: Simplest HTTP GET requester for Go with timeout support

MyHttp

Easy to use API to make timeout supported http GET requests in Go.

Go Report Card Coverage Status

MyHttp is for coders who don't want to write timeout support logic and don't want to deal with heavy APIs, just to make http GET request in Go.

It's battle-tested in production and has tests which even verifies connection leaking issues.

I'd been dealing with this issue myself, I read many documents, and saw that there are no simple and lightweight APIs to do http GET request with timeout logic. So, I created MyHttp in one of my projects and wanted to move it here.

Installation

go get github.com/inancgumus/myhttp

Documentation

See MyHttp GoDoc for the documentation.

Usage example

Get

Get simply gets the url and returns an http.Response.

import (
	"time"
	"github.com/inancgumus/myhttp"
)

mh := myhttp.New(time.Second * 10) // timeout after 10 seconds

res, err := mh.Get("http://www.domain.com/foo")
if err != nil {
	panic(err)
}

// use res here...

WrapGet

WrapGet accepts a function in its second argument and runs it after getting the http.Response from the url and automatically closes the http.Response.Body, in case you may forget to close it.

import (
	"time"
	"github.com/inancgumus/myhttp"
)

mh := myhttp.New(time.Second * 10) // timeout after 10 seconds

err := mh.WrapGet("http://www.domain.com/foo", func(r *http.Response) error {
	// use res here...
	// MyHttp will automatically close http.Response.Body for you after this func ends.
})

if err != nil {
	panic(err)
}

Author

Inanc Gumus โ€“ @inancgumus

Distributed under the MIT license. See LICENSE for more information.

Contributing

  1. Fork it (https://github.com/inancgumus/myhttp/fork)
  2. Create your feature branch (git checkout -b feature/foo)
  3. Commit your changes (git commit -am 'add: foo')
  4. Push to the branch (git push origin feature/foo)
  5. Create a new Pull Request

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory