Documentation ¶
Overview ¶
Package network client negotiator @author Arditya Kekasi
Package httpclient @author Daud Valentino
Index ¶
Constants ¶
const ( Accept = "Accept" AcceptCharset = "Accept-Charset" AcceptEncoding = "Accept-Encoding" AcceptLanguage = "Accept-Language" Authorization = "Authorization" CacheControl = "Cache-Control" ContentLength = "Content-Length" ContentMD5 = "Content-MD5" ContentType = "Content-Type" DoNotTrack = "DNT" IfMatch = "If-Match" IfModifiedSince = "If-Modified-Since" IfNoneMatch = "If-None-Match" IfRange = "If-Range" IfUnmodifiedSince = "If-Unmodified-Since" MaxForwards = "Max-Forwards" ProxyAuthorization = "Proxy-Authorization" Pragma = "Pragma" Range = "Range" Referer = "Referer" UserAgent = "User-Agent" TE = "TE" Via = "Via" Warning = "Warning" Cookie = "Cookie" Origin = "Origin" AcceptDatetime = "Accept-Datetime" XRequestedWith = "X-Requested-With" AccessControlAllowOrigin = "Access-Control-Allow-Origin" AccessControlAllowMethods = "Access-Control-Allow-Methods" AccessControlAllowHeaders = "Access-Control-Allow-Headers" AccessControlAllowCredentials = "Access-Control-Allow-Credentials" AccessControlExposeHeaders = "Access-Control-Expose-Headers" AccessControlMaxAge = "Access-Control-Max-Age" AccessControlRequestMethod = "Access-Control-Request-Method" AccessControlRequestHeaders = "Access-Control-Request-Headers" AcceptPatch = "Accept-Patch" AcceptRanges = "Accept-Ranges" Allow = "Allow" ContentEncoding = "Content-Encoding" ContentLanguage = "Content-Language" ContentLocation = "Content-Location" ContentDisposition = "Content-Disposition" ContentRange = "Content-Range" ETag = "ETag" Expires = "Expires" LastModified = "Last-Modified" Link = "Link" Location = "Location" P3P = "P3P" ProxyAuthenticate = "Proxy-Authenticate" Refresh = "Refresh" RetryAfter = "Retry-After" Server = "Server" SetCookie = "Set-Cookie" StrictTransportSecurity = "Strict-Transport-Security" TransferEncoding = "Transfer-Encoding" Upgrade = "Upgrade" Vary = "Vary" WWWAuthenticate = "WWW-Authenticate" Connection = "Connection" MediaTypeJSON = "application/json" ClinetID = "Client-ID" TransactionID = "Transaction-ID" )
HTTP headers
Variables ¶
This section is empty.
Functions ¶
func NewRequest ¶
NewRequest returns a new Request given a context, method, URL, and optional body.
If the provided body is also an io.Closer, the returned Request.Body is set to body and will be closed by the Client methods Do, Post, and PostForm, and Transport.RoundTrip.
NewRequest returns a Request suitable for use with Client.Do or Transport.RoundTrip. To create a request for use with testing a Server Handler, either use the NewRequest function in the net/http/httptest package, use ReadRequest, or manually update the Request fields. See the Request type's documentation for the difference between inbound and outbound request fields.
If body is of type *bytes.Buffer, *bytes.Reader, or *strings.Reader, the returned request's ContentLength is set to its exact value (instead of -1), GetBody is populated (so 307 and 308 redirects can replay the body), and Body is set to NoBody if the ContentLength is 0.
Types ¶
type Headers ¶
Headers content headers parameter
type RequestOptions ¶
type RequestOptions struct { Payload interface{} Request interface{} URL string Header Headers Method string TimeoutSecond int Context context.Context }
RequestOptions provide option parameter client request
type Response ¶
type Response struct { StatusCode int Body []byte BodyStr string Latency time.Duration Header http.Header }
ClientResponse representation of http client response
func Request ¶
func Request(option RequestOptions) (Response, error)
ClientRequest http client request with option
func (Response) DecodeJSON ¶
DecodeJSON decode response byte to struct
func (Response) GetLatency ¶
Header return http status response