mirror of
https://github.com/gofiber/fiber.git
synced 2025-02-23 19:44:02 +00:00
👷 Improve doc
This commit is contained in:
parent
5093eb8e27
commit
7c5fac67cf
53
client.go
53
client.go
@ -26,6 +26,7 @@ import (
|
|||||||
// and use CopyTo instead.
|
// and use CopyTo instead.
|
||||||
//
|
//
|
||||||
// Request instance MUST NOT be used from concurrently running goroutines.
|
// Request instance MUST NOT be used from concurrently running goroutines.
|
||||||
|
// Copy from fasthttp
|
||||||
type Request = fasthttp.Request
|
type Request = fasthttp.Request
|
||||||
|
|
||||||
// Response represents HTTP response.
|
// Response represents HTTP response.
|
||||||
@ -34,6 +35,7 @@ type Request = fasthttp.Request
|
|||||||
// and use CopyTo instead.
|
// and use CopyTo instead.
|
||||||
//
|
//
|
||||||
// Response instance MUST NOT be used from concurrently running goroutines.
|
// Response instance MUST NOT be used from concurrently running goroutines.
|
||||||
|
// Copy from fasthttp
|
||||||
type Response = fasthttp.Response
|
type Response = fasthttp.Response
|
||||||
|
|
||||||
// Args represents query arguments.
|
// Args represents query arguments.
|
||||||
@ -42,6 +44,7 @@ type Response = fasthttp.Response
|
|||||||
// and use CopyTo().
|
// and use CopyTo().
|
||||||
//
|
//
|
||||||
// Args instance MUST NOT be used from concurrently running goroutines.
|
// Args instance MUST NOT be used from concurrently running goroutines.
|
||||||
|
// Copy from fasthttp
|
||||||
type Args = fasthttp.Args
|
type Args = fasthttp.Args
|
||||||
|
|
||||||
var defaultClient Client
|
var defaultClient Client
|
||||||
@ -50,7 +53,11 @@ var defaultClient Client
|
|||||||
//
|
//
|
||||||
// It is safe calling Client methods from concurrently running goroutines.
|
// It is safe calling Client methods from concurrently running goroutines.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
// UserAgent is used in User-Agent request header.
|
||||||
UserAgent string
|
UserAgent string
|
||||||
|
|
||||||
|
// NoDefaultUserAgentHeader when set to true, causes the default
|
||||||
|
// User-Agent header to be excluded from the Request.
|
||||||
NoDefaultUserAgentHeader bool
|
NoDefaultUserAgentHeader bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -620,28 +627,6 @@ var (
|
|||||||
formFilePool sync.Pool
|
formFilePool sync.Pool
|
||||||
)
|
)
|
||||||
|
|
||||||
// AcquireAgent returns an empty Agent instance from createAgent pool.
|
|
||||||
//
|
|
||||||
// The returned Agent instance may be passed to ReleaseAgent when it is
|
|
||||||
// no longer needed. This allows Agent recycling, reduces GC pressure
|
|
||||||
// and usually improves performance.
|
|
||||||
func AcquireAgent() *Agent {
|
|
||||||
v := agentPool.Get()
|
|
||||||
if v == nil {
|
|
||||||
return &Agent{req: fasthttp.AcquireRequest()}
|
|
||||||
}
|
|
||||||
return v.(*Agent)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReleaseAgent returns a acquired via AcquireAgent to createAgent pool.
|
|
||||||
//
|
|
||||||
// It is forbidden accessing req and/or its' members after returning
|
|
||||||
// it to createAgent pool.
|
|
||||||
func ReleaseAgent(a *Agent) {
|
|
||||||
a.reset()
|
|
||||||
agentPool.Put(a)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AcquireClient returns an empty Client instance from client pool.
|
// AcquireClient returns an empty Client instance from client pool.
|
||||||
//
|
//
|
||||||
// The returned Client instance may be passed to ReleaseClient when it is
|
// The returned Client instance may be passed to ReleaseClient when it is
|
||||||
@ -666,11 +651,34 @@ func ReleaseClient(c *Client) {
|
|||||||
clientPool.Put(c)
|
clientPool.Put(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AcquireAgent returns an empty Agent instance from createAgent pool.
|
||||||
|
//
|
||||||
|
// The returned Agent instance may be passed to ReleaseAgent when it is
|
||||||
|
// no longer needed. This allows Agent recycling, reduces GC pressure
|
||||||
|
// and usually improves performance.
|
||||||
|
func AcquireAgent() *Agent {
|
||||||
|
v := agentPool.Get()
|
||||||
|
if v == nil {
|
||||||
|
return &Agent{req: fasthttp.AcquireRequest()}
|
||||||
|
}
|
||||||
|
return v.(*Agent)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReleaseAgent returns a acquired via AcquireAgent to createAgent pool.
|
||||||
|
//
|
||||||
|
// It is forbidden accessing req and/or its' members after returning
|
||||||
|
// it to createAgent pool.
|
||||||
|
func ReleaseAgent(a *Agent) {
|
||||||
|
a.reset()
|
||||||
|
agentPool.Put(a)
|
||||||
|
}
|
||||||
|
|
||||||
// AcquireRequest returns an empty Request instance from request pool.
|
// AcquireRequest returns an empty Request instance from request pool.
|
||||||
//
|
//
|
||||||
// The returned Request instance may be passed to ReleaseRequest when it is
|
// The returned Request instance may be passed to ReleaseRequest when it is
|
||||||
// no longer needed. This allows Request recycling, reduces GC pressure
|
// no longer needed. This allows Request recycling, reduces GC pressure
|
||||||
// and usually improves performance.
|
// and usually improves performance.
|
||||||
|
// Copy from fasthttp
|
||||||
func AcquireRequest() *Request {
|
func AcquireRequest() *Request {
|
||||||
v := requestPool.Get()
|
v := requestPool.Get()
|
||||||
if v == nil {
|
if v == nil {
|
||||||
@ -683,6 +691,7 @@ func AcquireRequest() *Request {
|
|||||||
//
|
//
|
||||||
// It is forbidden accessing req and/or its' members after returning
|
// It is forbidden accessing req and/or its' members after returning
|
||||||
// it to request pool.
|
// it to request pool.
|
||||||
|
// Copy from fasthttp
|
||||||
func ReleaseRequest(req *Request) {
|
func ReleaseRequest(req *Request) {
|
||||||
req.Reset()
|
req.Reset()
|
||||||
requestPool.Put(req)
|
requestPool.Put(req)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user