mirror of https://github.com/gofiber/fiber.git
✏️ Fix typo (#2518)
* Fix: typo in client.go * Fix: typo in ctx.go * Fix: typo in path.go * Fix: typo in router.go * Fix: typo in adaptor.gopull/2520/head
parent
040aac94c6
commit
5967d36bc0
34
client.go
34
client.go
|
@ -78,50 +78,50 @@ type Client struct {
|
||||||
JSONDecoder utils.JSONUnmarshal
|
JSONDecoder utils.JSONUnmarshal
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get returns a agent with http method GET.
|
// Get returns an agent with http method GET.
|
||||||
func Get(url string) *Agent { return defaultClient.Get(url) }
|
func Get(url string) *Agent { return defaultClient.Get(url) }
|
||||||
|
|
||||||
// Get returns a agent with http method GET.
|
// Get returns an agent with http method GET.
|
||||||
func (c *Client) Get(url string) *Agent {
|
func (c *Client) Get(url string) *Agent {
|
||||||
return c.createAgent(MethodGet, url)
|
return c.createAgent(MethodGet, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Head returns a agent with http method HEAD.
|
// Head returns an agent with http method HEAD.
|
||||||
func Head(url string) *Agent { return defaultClient.Head(url) }
|
func Head(url string) *Agent { return defaultClient.Head(url) }
|
||||||
|
|
||||||
// Head returns a agent with http method GET.
|
// Head returns an agent with http method GET.
|
||||||
func (c *Client) Head(url string) *Agent {
|
func (c *Client) Head(url string) *Agent {
|
||||||
return c.createAgent(MethodHead, url)
|
return c.createAgent(MethodHead, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Post sends POST request to the given url.
|
// Post sends POST request to the given URL.
|
||||||
func Post(url string) *Agent { return defaultClient.Post(url) }
|
func Post(url string) *Agent { return defaultClient.Post(url) }
|
||||||
|
|
||||||
// Post sends POST request to the given url.
|
// Post sends POST request to the given URL.
|
||||||
func (c *Client) Post(url string) *Agent {
|
func (c *Client) Post(url string) *Agent {
|
||||||
return c.createAgent(MethodPost, url)
|
return c.createAgent(MethodPost, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put sends PUT request to the given url.
|
// Put sends PUT request to the given URL.
|
||||||
func Put(url string) *Agent { return defaultClient.Put(url) }
|
func Put(url string) *Agent { return defaultClient.Put(url) }
|
||||||
|
|
||||||
// Put sends PUT request to the given url.
|
// Put sends PUT request to the given URL.
|
||||||
func (c *Client) Put(url string) *Agent {
|
func (c *Client) Put(url string) *Agent {
|
||||||
return c.createAgent(MethodPut, url)
|
return c.createAgent(MethodPut, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patch sends PATCH request to the given url.
|
// Patch sends PATCH request to the given URL.
|
||||||
func Patch(url string) *Agent { return defaultClient.Patch(url) }
|
func Patch(url string) *Agent { return defaultClient.Patch(url) }
|
||||||
|
|
||||||
// Patch sends PATCH request to the given url.
|
// Patch sends PATCH request to the given URL.
|
||||||
func (c *Client) Patch(url string) *Agent {
|
func (c *Client) Patch(url string) *Agent {
|
||||||
return c.createAgent(MethodPatch, url)
|
return c.createAgent(MethodPatch, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete sends DELETE request to the given url.
|
// Delete sends DELETE request to the given URL.
|
||||||
func Delete(url string) *Agent { return defaultClient.Delete(url) }
|
func Delete(url string) *Agent { return defaultClient.Delete(url) }
|
||||||
|
|
||||||
// Delete sends DELETE request to the given url.
|
// Delete sends DELETE request to the given URL.
|
||||||
func (c *Client) Delete(url string) *Agent {
|
func (c *Client) Delete(url string) *Agent {
|
||||||
return c.createAgent(MethodDelete, url)
|
return c.createAgent(MethodDelete, url)
|
||||||
}
|
}
|
||||||
|
@ -801,7 +801,7 @@ func (a *Agent) String() (int, string, []error) {
|
||||||
return code, utils.UnsafeString(body), errs
|
return code, utils.UnsafeString(body), errs
|
||||||
}
|
}
|
||||||
|
|
||||||
// Struct returns the status code, bytes body and errors of url.
|
// Struct returns the status code, bytes body and errors of URL.
|
||||||
// And bytes body will be unmarshalled to given v.
|
// And bytes body will be unmarshalled to given v.
|
||||||
//
|
//
|
||||||
// it's not safe to use Agent after calling [Agent.Struct]
|
// it's not safe to use Agent after calling [Agent.Struct]
|
||||||
|
@ -889,7 +889,7 @@ func AcquireClient() *Client {
|
||||||
|
|
||||||
// ReleaseClient returns c acquired via AcquireClient to client pool.
|
// ReleaseClient returns c acquired via AcquireClient to client pool.
|
||||||
//
|
//
|
||||||
// It is forbidden accessing req and/or its' members after returning
|
// It is forbidden accessing req and/or it's members after returning
|
||||||
// it to client pool.
|
// it to client pool.
|
||||||
func ReleaseClient(c *Client) {
|
func ReleaseClient(c *Client) {
|
||||||
c.UserAgent = ""
|
c.UserAgent = ""
|
||||||
|
@ -913,9 +913,9 @@ func AcquireAgent() *Agent {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReleaseAgent returns a acquired via AcquireAgent to Agent pool.
|
// ReleaseAgent returns an acquired via AcquireAgent to Agent pool.
|
||||||
//
|
//
|
||||||
// It is forbidden accessing req and/or its' members after returning
|
// It is forbidden accessing req and/or it's members after returning
|
||||||
// it to Agent pool.
|
// it to Agent pool.
|
||||||
func ReleaseAgent(a *Agent) {
|
func ReleaseAgent(a *Agent) {
|
||||||
a.reset()
|
a.reset()
|
||||||
|
@ -942,7 +942,7 @@ func AcquireResponse() *Response {
|
||||||
|
|
||||||
// ReleaseResponse return resp acquired via AcquireResponse to response pool.
|
// ReleaseResponse return resp acquired via AcquireResponse to response pool.
|
||||||
//
|
//
|
||||||
// It is forbidden accessing resp and/or its' members after returning
|
// It is forbidden accessing resp and/or it's members after returning
|
||||||
// it to response pool.
|
// it to response pool.
|
||||||
// Copy from fasthttp
|
// Copy from fasthttp
|
||||||
func ReleaseResponse(resp *Response) {
|
func ReleaseResponse(resp *Response) {
|
||||||
|
|
2
ctx.go
2
ctx.go
|
@ -904,7 +904,7 @@ func (c *Ctx) Next() error {
|
||||||
// Increment handler index
|
// Increment handler index
|
||||||
c.indexHandler++
|
c.indexHandler++
|
||||||
var err error
|
var err error
|
||||||
// Did we executed all route handlers?
|
// Did we execute all route handlers?
|
||||||
if c.indexHandler < len(c.route.Handlers) {
|
if c.indexHandler < len(c.route.Handlers) {
|
||||||
// Continue route stack
|
// Continue route stack
|
||||||
err = c.route.Handlers[c.indexHandler](c)
|
err = c.route.Handlers[c.indexHandler](c)
|
||||||
|
|
|
@ -27,7 +27,7 @@ func HTTPHandler(h http.Handler) fiber.Handler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConvertRequest converts a fiber.Ctx to an http.Request.
|
// ConvertRequest converts a fiber.Ctx to a http.Request.
|
||||||
// forServer should be set to true when the http.Request is going to be passed to a http.Handler.
|
// forServer should be set to true when the http.Request is going to be passed to a http.Handler.
|
||||||
func ConvertRequest(c *fiber.Ctx, forServer bool) (*http.Request, error) {
|
func ConvertRequest(c *fiber.Ctx, forServer bool) (*http.Request, error) {
|
||||||
var req http.Request
|
var req http.Request
|
||||||
|
|
8
path.go
8
path.go
|
@ -46,7 +46,7 @@ type routeSegment struct {
|
||||||
|
|
||||||
// different special routing signs
|
// different special routing signs
|
||||||
const (
|
const (
|
||||||
wildcardParam byte = '*' // indicates a optional greedy parameter
|
wildcardParam byte = '*' // indicates an optional greedy parameter
|
||||||
plusParam byte = '+' // indicates a required greedy parameter
|
plusParam byte = '+' // indicates a required greedy parameter
|
||||||
optionalParam byte = '?' // concludes a parameter by name and makes it optional
|
optionalParam byte = '?' // concludes a parameter by name and makes it optional
|
||||||
paramStarterChar byte = ':' // start character for a parameter with name
|
paramStarterChar byte = ':' // start character for a parameter with name
|
||||||
|
@ -138,7 +138,7 @@ func RoutePatternMatch(path, pattern string, cfg ...Config) bool {
|
||||||
|
|
||||||
patternPretty := pattern
|
patternPretty := pattern
|
||||||
|
|
||||||
// Case sensitive routing, all to lowercase
|
// Case-sensitive routing, all to lowercase
|
||||||
if !config.CaseSensitive {
|
if !config.CaseSensitive {
|
||||||
patternPretty = utils.ToLower(patternPretty)
|
patternPretty = utils.ToLower(patternPretty)
|
||||||
path = utils.ToLower(path)
|
path = utils.ToLower(path)
|
||||||
|
@ -228,7 +228,7 @@ func addParameterMetaInfo(segs []*routeSegment) []*routeSegment {
|
||||||
// check how often the compare part is in the following const parts
|
// check how often the compare part is in the following const parts
|
||||||
if segs[i].IsParam {
|
if segs[i].IsParam {
|
||||||
// check if parameter segments are directly after each other and if one of them is greedy
|
// check if parameter segments are directly after each other and if one of them is greedy
|
||||||
// in case the next parameter or the current parameter is not a wildcard its not greedy, we only want one character
|
// in case the next parameter or the current parameter is not a wildcard it's not greedy, we only want one character
|
||||||
if segLen > i+1 && !segs[i].IsGreedy && segs[i+1].IsParam && !segs[i+1].IsGreedy {
|
if segLen > i+1 && !segs[i].IsGreedy && segs[i+1].IsParam && !segs[i+1].IsGreedy {
|
||||||
segs[i].Length = 1
|
segs[i].Length = 1
|
||||||
}
|
}
|
||||||
|
@ -483,7 +483,7 @@ func (routeParser *routeParser) getMatch(detectionPath, path string, params *[ma
|
||||||
if !segment.IsParam {
|
if !segment.IsParam {
|
||||||
i = segment.Length
|
i = segment.Length
|
||||||
// is optional part or the const part must match with the given string
|
// is optional part or the const part must match with the given string
|
||||||
// check if the end of the segment is a optional slash
|
// check if the end of the segment is an optional slash
|
||||||
if segment.HasOptionalSlash && partLen == i-1 && detectionPath == segment.Const[:i-1] {
|
if segment.HasOptionalSlash && partLen == i-1 && detectionPath == segment.Const[:i-1] {
|
||||||
i--
|
i--
|
||||||
} else if !(i <= partLen && detectionPath[:i] == segment.Const) {
|
} else if !(i <= partLen && detectionPath[:i] == segment.Const) {
|
||||||
|
|
|
@ -184,7 +184,7 @@ func (app *App) handler(rctx *fasthttp.RequestCtx) { //revive:disable-line:confu
|
||||||
func (app *App) addPrefixToRoute(prefix string, route *Route) *Route {
|
func (app *App) addPrefixToRoute(prefix string, route *Route) *Route {
|
||||||
prefixedPath := getGroupPath(prefix, route.Path)
|
prefixedPath := getGroupPath(prefix, route.Path)
|
||||||
prettyPath := prefixedPath
|
prettyPath := prefixedPath
|
||||||
// Case sensitive routing, all to lowercase
|
// Case-sensitive routing, all to lowercase
|
||||||
if !app.config.CaseSensitive {
|
if !app.config.CaseSensitive {
|
||||||
prettyPath = utils.ToLower(prettyPath)
|
prettyPath = utils.ToLower(prettyPath)
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ func (app *App) register(method, pathRaw string, group *Group, handlers ...Handl
|
||||||
}
|
}
|
||||||
// Create a stripped path in-case sensitive / trailing slashes
|
// Create a stripped path in-case sensitive / trailing slashes
|
||||||
pathPretty := pathRaw
|
pathPretty := pathRaw
|
||||||
// Case sensitive routing, all to lowercase
|
// Case-sensitive routing, all to lowercase
|
||||||
if !app.config.CaseSensitive {
|
if !app.config.CaseSensitive {
|
||||||
pathPretty = utils.ToLower(pathPretty)
|
pathPretty = utils.ToLower(pathPretty)
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ func (app *App) register(method, pathRaw string, group *Group, handlers ...Handl
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *App) registerStatic(prefix, root string, config ...Static) {
|
func (app *App) registerStatic(prefix, root string, config ...Static) {
|
||||||
// For security we want to restrict to the current work directory.
|
// For security, we want to restrict to the current work directory.
|
||||||
if root == "" {
|
if root == "" {
|
||||||
root = "."
|
root = "."
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ func (app *App) registerStatic(prefix, root string, config ...Static) {
|
||||||
if prefix[0] != '/' {
|
if prefix[0] != '/' {
|
||||||
prefix = "/" + prefix
|
prefix = "/" + prefix
|
||||||
}
|
}
|
||||||
// in case sensitive routing, all to lowercase
|
// in case-sensitive routing, all to lowercase
|
||||||
if !app.config.CaseSensitive {
|
if !app.config.CaseSensitive {
|
||||||
prefix = utils.ToLower(prefix)
|
prefix = utils.ToLower(prefix)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue