Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Index your code
hub
/
github.com/cizixs/gohttp
/ functions
Functions
67 in github.com/cizixs/gohttp
⨍
Functions
67
◇
Types & classes
8
↓ 42 callers
Method
New
New clones current client struct and returns it This is useful to initialize some common parameters and send different requests with differenet paths/
gohttp.go:193
↓ 20 callers
Method
Get
Get handles HTTP GET request, and return response to user Note that the response is not `http.Response`, but a thin wrapper which does exactly what it
gohttp.go:458
↓ 7 callers
Method
Do
Do takes HTTP and url, then makes the request, return the response. All other HTTP methods will call `Do` behind the scene, and it can be used directl
gohttp.go:403
↓ 7 callers
Method
Post
Post handles HTTP POST request
gohttp.go:463
↓ 6 callers
Method
Header
Header sets request header data
gohttp.go:588
↓ 6 callers
Method
logf
log writes a formatted log message record to Stderr
gohttp.go:226
↓ 5 callers
Method
Body
Body accepts `io.Reader`, will read data from it and use it as request body. This doee not set `Content-Type` header, so users should use `Header(key,
gohttp.go:664
↓ 5 callers
Method
Path
Path concatenates base url with resource path. Path can be with or without slash `/` at both end, it will be handled properly. Usage: gohttp.New().Pa
gohttp.go:509
↓ 5 callers
Method
Query
Query set parameter query string
gohttp.go:568
↓ 3 callers
Method
URL
URL sets the base url for the client, this can be overrided by the parameter of the final GET/POST/PUT method
gohttp.go:495
↓ 2 callers
Method
AsBytes
AsBytes return the response body as byte slice An error will be returned if the body can not be read as bytes
gohttp.go:67
↓ 2 callers
Method
Delete
Delete handles HTTP DELETE request
gohttp.go:479
↓ 2 callers
Method
Head
Head handles HTTP HEAD request HEAD request works the same way as GET, except the response body is empty.
gohttp.go:469
↓ 2 callers
Method
JSON
JSON accepts a string as data, and sets it as body, and send it as application/json If the actual method does not support body or json data, such as `
gohttp.go:609
↓ 2 callers
Method
Options
Options handles HTTP OPTIONS request
gohttp.go:489
↓ 2 callers
Method
Patch
Patch handles HTTP PATCH request
gohttp.go:484
↓ 2 callers
Method
Put
Put handles HTTP PUT request
gohttp.go:474
↓ 2 callers
Method
Timeout
Timeout sets the wait limit for a request to finish. This time includes connection time, redirectoin time, and read response body time. If request doe
gohttp.go:538
↓ 2 callers
Function
copyMap
(src map[string]string)
gohttp.go:172
↓ 1 callers
Method
AsJSON
AsJSON parses response body to a struct Usage: user := &User{} resp.AsJSON(user) fmt.Printf("%s\n", user.Name)
gohttp.go:76
↓ 1 callers
Method
AsString
AsString returns the response data as string An error wil bw returned if the body can not be read as string
gohttp.go:57
↓ 1 callers
Method
Cookie
Cookie set client cookie, the argument is a standard `http.Cookie`
gohttp.go:560
↓ 1 callers
Method
File
File adds a file in request body, and sends it to server Multiple files can be added by calling this method many times
gohttp.go:673
↓ 1 callers
Method
Form
Form accepts a struct, uses it as body data, and sent it as application/www-x-form-urlencoded If the actual method does not support body or form data,
gohttp.go:652
↓ 1 callers
Method
JSONStruct
JSONStruct accepts a struct as data, and sets it as body, and send it as application/json If the actual method does not support body or json data, suc
gohttp.go:623
↓ 1 callers
Function
New
New returns a new GoClient with default values
gohttp.go:153
↓ 1 callers
Method
QueryStruct
QueryStruct parses a struct as query strings On how it works, please refer to github.com/google/go-querystring repo
gohttp.go:575
↓ 1 callers
Method
Retries
Retries set how many request attempts will be conducted if error happens for a request. number <= 1 means no retries, send one request and finish.
gohttp.go:553
↓ 1 callers
Method
prepareFiles
()
gohttp.go:262
↓ 1 callers
Method
prepareRequest
prepareRequest does all the preparation jobs for `gohttp`. The main job is create and configure all structs like `Transport`, `Dialer`, `Client` accor
gohttp.go:306
↓ 1 callers
Method
setupClient
setupClient handles the connection details from http client to TCP connections. Timeout, proxy, TLS config ..., these are very important but rarely us
gohttp.go:235
Method
BasicAuth
BasicAuth allows simple username/password authentication
gohttp.go:581
Method
Body
()
gohttp.go:597
Method
Body
Body returns io.Reader from form data. Form data is a collection of many key-value pairs, so we use go-querystring to parse it to string, then create
gohttp.go:641
Method
Debug
Debug sets the debug mode of go http. By default, debug mode is off. This is only for testing and debugging purpose, it will print out detail informa
gohttp.go:392
Function
Delete
Delete provides a shortcut to send `DELETE` request It is used to remove a resource from server
gohttp.go:695
Function
Get
Get provides a shortcut to send `GET` request
gohttp.go:684
Function
Head
Head provides a shortcut to send `HEAD` request
gohttp.go:689
Function
Options
Options provides a shortcut to send `OPTIONS` request
gohttp.go:700
Function
Patch
Patch provides a shortcut to send `PATCH` request
gohttp.go:715
Function
Post
Post provides a shortcut to send `POST` request
gohttp.go:705
Method
Proxy
Proxy sets proxy server the client uses. If it is empty, `gohttp` will try to load proxy settings from environment variable Usage: gohttp.New().Proxy
gohttp.go:524
Function
Put
Put provides a shortcut to send `PUT` request
gohttp.go:710
Method
TLSHandshakeTimeout
TLSHandshakeTimeout sets the wait limit for performing TLS handshake. Default value for go1.6 is 10s, change this value to suit yourself.
gohttp.go:546
Function
TestCloneClient
(t *testing.T)
gohttp_test.go:37
Function
TestCookie
(t *testing.T)
gohttp_test.go:226
Function
TestDelete
(t *testing.T)
gohttp_test.go:126
Function
TestGet
(t *testing.T)
gohttp_test.go:20
Function
TestGetWithHeader
(t *testing.T)
gohttp_test.go:334
Function
TestGetWithPath
(t *testing.T)
gohttp_test.go:258
Function
TestGetWithQuery
(t *testing.T)
gohttp_test.go:295
Function
TestGetWithQueryStruct
(t *testing.T)
gohttp_test.go:314
Function
TestGetWithURL
(t *testing.T)
gohttp_test.go:242
Function
TestHead
(t *testing.T)
gohttp_test.go:111
Function
TestOptions
(t *testing.T)
gohttp_test.go:168
Function
TestPatch
(t *testing.T)
gohttp_test.go:154
Function
TestPost
(t *testing.T)
gohttp_test.go:140
Function
TestPostFiles
(t *testing.T)
gohttp_test.go:444
Function
TestPostForm
(t *testing.T)
gohttp_test.go:350
Function
TestPostJSON
(t *testing.T)
gohttp_test.go:380
Function
TestPostJSONStruct
(t *testing.T)
gohttp_test.go:409
Function
TestPut
(t *testing.T)
gohttp_test.go:182
Function
TestResponseAsBytes
(t *testing.T)
gohttp_test.go:73
Function
TestResponseAsJSON
(t *testing.T)
gohttp_test.go:91
Function
TestResponseAsString
(t *testing.T)
gohttp_test.go:55
Function
TestRetries
(t *testing.T)
gohttp_test.go:208
Function
TestTimeout
(t *testing.T)
gohttp_test.go:196