Checks, if the specified extensions or content types are acceptable.
Based on the request’s Accept HTTP header.
Signaturefunc (c *Ctx) Accepts(offers ...string) stringfunc (c *Ctx) AcceptsCharsets(offers ...string) stringfunc (c *Ctx) AcceptsEncodings(offers ...string) stringfunc (c *Ctx) AcceptsLanguages(offers ...string) string
Example// Accept: text/*, application/jsonapp.Get("/", func(c *fiber.Ctx) error {c.Accepts("html") // "html"c.Accepts("text/html") // "text/html"c.Accepts("json", "text") // "json"c.Accepts("application/json") // "application/json"c.Accepts("image/png") // ""c.Accepts("png") // ""// ...})
Fiber provides similar functions for the other accept headers.
// Accept-Charset: utf-8, iso-8859-1;q=0.2// Accept-Encoding: gzip, compress;q=0.2// Accept-Language: en;q=0.8, nl, ruapp.Get("/", func(c *fiber.Ctx) error {c.AcceptsCharsets("utf-16", "iso-8859-1")// "iso-8859-1"c.AcceptsEncodings("compress", "br")// "compress"c.AcceptsLanguages("pt", "nl", "ru")// "nl"// ...})
Appends the specified value to the HTTP response header field.
If the header is not already set, it creates the header with the specified value.
Signaturefunc (c *Ctx) Append(field string, values ...string)
Exampleapp.Get("/", func(c *fiber.Ctx) error {c.Append("Link", "http://google.com", "http://localhost")// => Link: http://localhost, http://google.comc.Append("Link", "Test")// => Link: http://localhost, http://google.com, Test// ...})
Sets the HTTP response Content-Disposition header field to attachment
.
Signaturefunc (c *Ctx) Attachment(filename ...string)
Exampleapp.Get("/", func(c *fiber.Ctx) error {c.Attachment()// => Content-Disposition: attachmentc.Attachment("./upload/images/logo.png")// => Content-Disposition: attachment; filename="logo.png"// => Content-Type: image/png// ...})
Returns the *App reference so you could easily access all application settings.
Signaturefunc (c *Ctx) App() *App
Exampleapp.Get("/stack", func(c *fiber.Ctx) error {return c.JSON(c.App().Stack())})
Returns the base URL (protocol + host) as a string
.
Signaturefunc (c *Ctx) BaseURL() string
Example// GET https://example.com/page#chapter-1app.Get("/", func(c *fiber.Ctx) error {c.BaseURL() // https://example.com// ...})
Returns the raw request body.
Signaturefunc (c *Ctx) Body() []byte
Example// curl -X POST http://localhost:8080 -d user=johnapp.Post("/", func(c *fiber.Ctx) error {// Get raw body from POST request:return c.Send(c.Body()) // []byte("user=john")})
Returned value is only valid within the handler. Do not store any references. Make copies or use the
Immutable
setting instead. Read more...
Binds the request body to a struct. BodyParser
supports decoding query parameters and the following content types based on the Content-Type
header:
application/json
application/xml
application/x-www-form-urlencoded
multipart/form-data
Signaturefunc (c *Ctx) BodyParser(out interface{}) error
Example// Field names should start with an uppercase lettertype Person struct {Name string `json:"name" xml:"name" form:"name"`Pass string `json:"pass" xml:"pass" form:"pass"`}app.Post("/", func(c *fiber.Ctx) error {p := new(Person)if err := c.BodyParser(p); err != nil {return err}log.Println(p.Name) // johnlog.Println(p.Pass) // doe// ...})// Run tests with the following curl commands// curl -X POST -H "Content-Type: application/json" --data "{\"name\":\"john\",\"pass\":\"doe\"}" localhost:3000// curl -X POST -H "Content-Type: application/xml" --data "<login><name>john</name><pass>doe</pass></login>" localhost:3000// curl -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "name=john&pass=doe" localhost:3000// curl -X POST -F name=john -F pass=doe http://localhost:3000// curl -X POST "http://localhost:3000/?name=john&pass=doe"
Expire a client cookie (or all cookies if left empty)
Signaturefunc (c *Ctx) ClearCookie(key ...string)
Exampleapp.Get("/", func(c *fiber.Ctx) error {// Clears all cookies:c.ClearCookie()// Expire specific cookie by name:c.ClearCookie("user")// Expire multiple cookies by names:c.ClearCookie("token", "session", "track_id", "version")// ...})
Web browsers and other compliant clients will only clear the cookie if the given options are identical to those when creating the cookie, excluding expires and maxAge. ClearCookie will not set these values for you - a technique similar to the one shown below should be used to ensure your cookie is deleted.
Exampleapp.Get("/set", func(c *fiber.Ctx) error {c.Cookie(&fiber.Cookie{Name: "token",Value: "randomvalue",Expires: time.Now().Add(24 * time.Hour),HTTPOnly: true,SameSite: "lax",})// ...})app.Get("/delete", func(c *fiber.Ctx) error {c.Cookie(&fiber.Cookie{Name: "token",// Set expiry date to the pastExpires: time.Now().Add(-(time.Hour * 2)),HTTPOnly: true,SameSite: "lax",})// ...})
Returns *fasthttp.RequestCtx that is compatible with the context.Context interface that requires a deadline, a cancellation signal, and other values across API boundaries.
Signaturefunc (c *Ctx) Context() *fasthttp.RequestCtx
Please read the Fasthttp Documentation for more information.
Set cookie
Signaturefunc (c *Ctx) Cookie(cookie *Cookie)
type Cookie struct {Name string `json:"name"`Value string `json:"value"`Path string `json:"path"`Domain string `json:"domain"`MaxAge int `json:"max_age"`Expires time.Time `json:"expires"`Secure bool `json:"secure"`HTTPOnly bool `json:"http_only"`SameSite string `json:"same_site"`}
Exampleapp.Get("/", func(c *fiber.Ctx) error {// Create cookiecookie := new(fiber.Cookie)cookie.Name = "john"cookie.Value = "doe"cookie.Expires = time.Now().Add(24 * time.Hour)// Set cookiec.Cookie(cookie)// ...})
Get cookie value by key, you could pass an optional default value that will be returned if the cookie key does not exist.
Signatures
func (c *Ctx) Cookies(key string, defaultValue ...string) string
Exampleapp.Get("/", func(c *fiber.Ctx) error {// Get cookie by key:c.Cookies("name") // "john"c.Cookies("empty", "doe") // "doe"// ...})
Returned value is only valid within the handler. Do not store any references. Make copies or use the
Immutable
setting instead. Read more...
Transfers the file from path as an attachment
.
Typically, browsers will prompt the user to download. By default, the Content-Disposition header filename=
parameter is the file path (this typically appears in the browser dialog).
Override this default with the filename parameter.
Signaturefunc (c *Ctx) Download(file string, filename ...string) error
Exampleapp.Get("/", func(c *fiber.Ctx) error {return c.Download("./files/report-12345.pdf");// => Download report-12345.pdfreturn c.Download("./files/report-12345.pdf", "report.pdf");// => Download report.pdf})
Request return the *fasthttp.Request pointer
Signature
Signaturefunc (c *Ctx) Request() *fasthttp.Request
Example
app.Get("/", func(c *fiber.Ctx) error {c.Request().Header.Method()// => []byte("GET")})
Request return the *fasthttp.Response pointer
Signature
Signaturefunc (c *Ctx) Response() *fasthttp.Response
Example
app.Get("/", func(c *fiber.Ctx) error {c.Response().Write([]byte("Hello, World!"))// => "Hello, World!"})
Performs content-negotiation on the Accept HTTP header. It uses Accepts to select a proper format.
If the header is not specified or there is no proper format, text/plain is used.
Signaturefunc (c *Ctx) Format(body interface{}) error
Exampleapp.Get("/", func(c *fiber.Ctx) error {// Accept: text/plainc.Format("Hello, World!")// => Hello, World!// Accept: text/htmlc.Format("Hello, World!")// => <p>Hello, World!</p>// Accept: application/jsonc.Format("Hello, World!")// => "Hello, World!"// ..})
MultipartForm files can be retrieved by name, the first file from the given key is returned.
Signaturefunc (c *Ctx) FormFile(key string) (*multipart.FileHeader, error)
Exampleapp.Post("/", func(c *fiber.Ctx) error {// Get first file from form field "document":file, err := c.FormFile("document")// Save file to root directory:return c.SaveFile(file, fmt.Sprintf("./%s", file.Filename))})
Any form values can be retrieved by name, the first value from the given key is returned.
Signaturefunc (c *Ctx) FormValue(key string, defaultValue ...string) string
Exampleapp.Post("/", func(c *fiber.Ctx) error {// Get first value from form field "name":c.FormValue("name")// => "john" or "" if not exist// ..})
Returned value is only valid within the handler. Do not store any references. Make copies or use the
Immutable
setting instead. Read more...
https://expressjs.com/en/4x/api.html#req.fresh
Signaturefunc (c *Ctx) Fresh() bool
Returns the HTTP request header specified by the field.
The match is case-insensitive.
Signaturefunc (c *Ctx) Get(key string, defaultValue ...string) string
Exampleapp.Get("/", func(c *fiber.Ctx) error {c.Get("Content-Type") // "text/plain"c.Get("CoNtEnT-TypE") // "text/plain"c.Get("something", "john") // "john"// ..})
Returned value is only valid within the handler. Do not store any references. Make copies or use the
Immutable
setting instead. Read more...
Returns the hostname derived from the Host HTTP header.
Signaturefunc (c *Ctx) Hostname() string
Example// GET http://google.com/searchapp.Get("/", func(c *fiber.Ctx) error {c.Hostname() // "google.com"// ...})
Returned value is only valid within the handler. Do not store any references. Make copies or use the
Immutable
setting instead. Read more...
Returns the remote IP address of the request.
Signaturefunc (c *Ctx) IP() string
Exampleapp.Get("/", func(c *fiber.Ctx) error {c.IP() // "127.0.0.1"// ...})
Returns an array of IP addresses specified in the X-Forwarded-For request header.
Signaturefunc (c *Ctx) IPs() []string
Example// X-Forwarded-For: proxy1, 127.0.0.1, proxy3app.Get("/", func(c *fiber.Ctx) error {c.IPs() // ["proxy1", "127.0.0.1", "proxy3"]// ...})
Returns the matching content type, if the incoming request’s Content-Type HTTP header field matches the MIME type specified by the type parameter.
If the request has no body, it returns false.
Signaturefunc (c *Ctx) Is(extension string) bool
Example// Content-Type: text/html; charset=utf-8app.Get("/", func(c *fiber.Ctx) error {c.Is("html") // truec.Is(".html") // truec.Is("json") // false// ...})
Converts any interface or string to JSON using the segmentio/encoding package.
JSON also sets the content header to application/json.
Signaturefunc (c *Ctx) JSON(data interface{}) error
Exampletype SomeStruct struct {Name stringAge uint8}app.Get("/json", func(c *fiber.Ctx) error {// Create data struct:data := SomeStruct{Name: "Grame",Age: 20,}return c.JSON(data)// => Content-Type: application/json// => "{"Name": "Grame", "Age": 20}"return c.JSON(fiber.Map{"name": "Grame","age": 20,})// => Content-Type: application/json// => "{"name": "Grame", "age": 20}"})
Sends a JSON response with JSONP support. This method is identical to JSON, except that it opts-in to JSONP callback support. By default, the callback name is simply callback.
Override this by passing a named string in the method.
Signaturefunc (c *Ctx) JSONP(data interface{}, callback ...string) error
Exampletype SomeStruct struct {name stringage uint8}app.Get("/", func(c *fiber.Ctx) error {// Create data struct:data := SomeStruct{name: "Grame",age: 20,}return c.JSONP(data)// => callback({"name": "Grame", "age": 20})return c.JSONP(data, "customFunc")// => customFunc({"name": "Grame", "age": 20})})
Joins the links followed by the property to populate the response’s Link HTTP header field.
Signaturefunc (c *Ctx) Links(link ...string)
Exampleapp.Get("/", func(c *fiber.Ctx) error {c.Links("http://api.example.com/users?page=2", "next","http://api.example.com/users?page=5", "last",)// Link: <http://api.example.com/users?page=2>; rel="next",// <http://api.example.com/users?page=5>; rel="last"// ...})
A method that stores variables scoped to the request and, therefore, are available only to the routes that match the request.
This is useful if you want to pass some specific data to the next middleware.
Signaturefunc (c *Ctx) Locals(key string, value ...interface{}) interface{}
Exampleapp.Use(func(c *fiber.Ctx) error {c.Locals("user", "admin")return c.Next()})app.Get("/admin", func(c *fiber.Ctx) error {if c.Locals("user") == "admin" {return c.Status(200).SendString("Welcome, admin!")}return c.SendStatus(403)})
Sets the response Location HTTP header to the specified path parameter.
Signaturefunc (c *Ctx) Location(path string)
Exampleapp.Post("/", func(c *fiber.Ctx) error {return c.Location("http://example.com")return c.Location("/foo/bar")})
Returns a string corresponding to the HTTP method of the request: GET
, POST
, PUT
, and so on.
Optionally, you could override the method by passing a string.
Signaturefunc (c *Ctx) Method(override ...string) string
Exampleapp.Post("/", func(c *fiber.Ctx) error {c.Method() // "POST"c.Method("GET")c.Method() // GET// ...})
To access multipart form entries, you can parse the binary with MultipartForm()
. This returns a map[string][]string
, so given a key, the value will be a string slice.
Signaturefunc (c *Ctx) MultipartForm() (*multipart.Form, error)
Exampleapp.Post("/", func(c *fiber.Ctx) error {// Parse the multipart form:if form, err := c.MultipartForm(); err == nil {// => *multipart.Formif token := form.Value["token"]; len(token) > 0 {// Get key value:fmt.Println(token[0])}// Get all files from "documents" key:files := form.File["documents"]// => []*multipart.FileHeader// Loop through files:for _, file := range files {fmt.Println(file.Filename, file.Size, file.Header["Content-Type"][0])// => "tutorial.pdf" 360641 "application/pdf"// Save the files to disk:if err := c.SaveFile(file, fmt.Sprintf("./%s", file.Filename)); err != nil {return err}}}return err})
When Next is called, it executes the next method in the stack that matches the current route. You can pass an error struct within the method that will end the chaining and call the error handler.
Signaturefunc (c *Ctx) Next() error
Exampleapp.Get("/", func(c *fiber.Ctx) error {fmt.Println("1st route!")return c.Next()})app.Get("*", func(c *fiber.Ctx) error {fmt.Println("2nd route!")return c.Next()})app.Get("/", func(c *fiber.Ctx) error {fmt.Println("3rd route!")return c.SendString("Hello, World!")})
Returns the original request URL.
Signaturefunc (c *Ctx) OriginalURL() string
Example// GET http://example.com/search?q=somethingapp.Get("/", func(c *fiber.Ctx) error {c.OriginalURL() // "/search?q=something"// ...})
Returned value is only valid within the handler. Do not store any references. Make copies or use the
Immutable
setting instead. Read more...
Method can be used to get the route parameters, you could pass an optional default value that will be returned if the param key does not exist.
Defaults to empty string (""
), if the param doesn't exist.
Signaturefunc (c *Ctx) Params(key string, defaultValue ...string) string
Example// GET http://example.com/user/fennyapp.Get("/user/:name", func(c *fiber.Ctx) error {c.Params("name") // "fenny"// ...})// GET http://example.com/user/fenny/123app.Get("/user/*", func(c *fiber.Ctx) error {c.Params("*") // "fenny/123"c.Params("*1") // "fenny/123"// ...})
Unnamed route parameters(*, +) can be fetched by the character and the counter in the route.
Example// ROUTE: /v1/*/shop/*// GET: /v1/brand/4/shop/blue/xsc.Params("*1") // "brand/4"c.Params("*2") // "blue/xs"
For reasons of downward compatibility, the first parameter segment for the parameter character can also be accessed without the counter.
Exampleapp.Get("/v1/*/shop/*", func(c *fiber.Ctx) error {c.Params("*") // outputs the values of the first wildcard segment})
Returned value is only valid within the handler. Do not store any references. Make copies or use the
Immutable
setting instead. Read more...
Method can be used to get an integer from the route parameters. Please note if that parameter is not in the request, zero will be returned. If the parameter is NOT a number, zero and an error will be returned
Defaults to empty string (""
), if the param doesn't exist.
Signaturefunc (c *Ctx) Params(key string) (int, error)
Example// GET http://example.com/user/123app.Get("/user/:name", func(c *fiber.Ctx) error {id, err := c.ParamsInt("id") // int 123 and no error// ...})
This method is equivalent of using atoi
with ctx.Params
Contains the path part of the request URL. Optionally, you could override the path by passing a string.
Signaturefunc (c *Ctx) Path(override ...string) string
Example// GET http://example.com/users?sort=descapp.Get("/users", func(c *fiber.Ctx) error {c.Path() // "/users"c.Path("/john")c.Path() // "/john"// ...})
Contains the request protocol string: http
or https
for TLS requests.
Signaturefunc (c *Ctx) Protocol() string
Example// GET http://example.comapp.Get("/", func(c *fiber.Ctx) error {c.Protocol() // "http"// ...})
This property is an object containing a property for each query string parameter in the route, you could pass an optional default value that will be returned if the query key does not exist.
If there is no query string, it returns an empty string.
Signaturefunc (c *Ctx) Query(key string, defaultValue ...string) string
Example// GET http://example.com/shoes?order=desc&brand=nikeapp.Get("/", func(c *fiber.Ctx) error {c.Query("order") // "desc"c.Query("brand") // "nike"c.Query("empty", "nike") // "nike"// ...})
Returned value is only valid within the handler. Do not store any references. Make copies or use the
Immutable
setting instead. Read more...
This method is similar to BodyParser, but for query parameters.
Signaturefunc (c *Ctx) QueryParser(out interface{}) error
Example// Field names should start with an uppercase lettertype Person struct {Name string `query:"name"`Pass string `query:"pass"`Products []string `query:"products"`}app.Get("/", func(c *fiber.Ctx) error {p := new(Person)if err := c.QueryParser(p); err != nil {return err}log.Println(p.Name) // johnlog.Println(p.Pass) // doelog.Println(p.Products) // [shoe, hat]// ...})// Run tests with the following curl command// curl -X POST "http://localhost:3000/?name=john&pass=doe&products=shoe,hat"
A struct containing the type and a slice of ranges will be returned.
Signaturefunc (c *Ctx) Range(size int) (Range, error)
Example// Range: bytes=500-700, 700-900app.Get("/", func(c *fiber.Ctx) error {b := c.Range(1000)if b.Type == "bytes" {for r := range r.Ranges {fmt.Println(r)// [500, 700]}}})
Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an HTTP status code.
If not specified, status defaults to 302 Found.
Signaturefunc (c *Ctx) Redirect(location string, status ...int) error
Exampleapp.Get("/coffee", func(c *fiber.Ctx) error {return c.Redirect("/teapot")})app.Get("/teapot", func(c *fiber.Ctx) error {return c.Status(fiber.StatusTeapot).Send("🍵 short and stout 🍵")})
More examplesapp.Get("/", func(c *fiber.Ctx) error {return c.Redirect("/foo/bar")return c.Redirect("../login")return c.Redirect("http://example.com")return c.Redirect("http://example.com", 301)})
Renders a view with data and sends a text/html
response. By default Render
uses the default Go Template engine. If you want to use another View engine, please take a look at our Template middleware.
Signaturefunc (c *Ctx) Render(name string, bind interface{}, layouts ...string) error
Returns the matched Route struct.
Signaturefunc (c *Ctx) Route() *Route
Example// http://localhost:8080/helloapp.Get("/hello/:name", func(c *fiber.Ctx) error {r := c.Route()fmt.Println(r.Method, r.Path, r.Params, r.Handlers)// GET /hello/:name handler [name]// ...})
Method is used to save any multipart file to disk.
Signaturefunc (c *Ctx) SaveFile(fh *multipart.FileHeader, path string) error
Exampleapp.Post("/", func(c *fiber.Ctx) error {// Parse the multipart form:if form, err := c.MultipartForm(); err == nil {// => *multipart.Form// Get all files from "documents" key:files := form.File["documents"]// => []*multipart.FileHeader// Loop through files:for _, file := range files {fmt.Println(file.Filename, file.Size, file.Header["Content-Type"][0])// => "tutorial.pdf" 360641 "application/pdf"// Save the files to disk:if err := c.SaveFile(file, fmt.Sprintf("./%s", file.Filename)); err != nil {return err}}return err}})
A boolean property that is true
, if a TLS connection is established.
Signaturefunc (c *Ctx) Secure() bool
Example// Secure() method is equivalent to:c.Protocol() == "https"
Sets the HTTP response body.
Signaturefunc (c *Ctx) Send(body []byte) error
Exampleapp.Get("/", func(c *fiber.Ctx) error {return c.Send([]byte("Hello, World!")) // => "Hello, World!"})
Fiber also provides SendString
and SendStream
methods for raw inputs.
Use this if you don't need type assertion, recommended for faster performance.
Signaturefunc (c *Ctx) SendString(body string) errorfunc (c *Ctx) SendStream(stream io.Reader, size ...int) error
Exampleapp.Get("/", func(c *fiber.Ctx) error {return c.SendString("Hello, World!")// => "Hello, World!"return c.SendStream(bytes.NewReader([]byte("Hello, World!")))// => "Hello, World!"})
Transfers the file from the given path. Sets the Content-Type response HTTP header field based on the filenames extension.
Method use gzipping by default, set it to true to disable.
Signaturefunc (c *Ctx) SendFile(file string, compress ...bool) error
Exampleapp.Get("/not-found", func(c *fiber.Ctx) error {return c.SendFile("./public/404.html");// Disable compressionreturn c.SendFile("./static/index.html", false);})
Sets the status code and the correct status message in the body, if the response body is empty.
You can find all used status codes and messages here.
Signaturefunc (c *Ctx) SendStatus(status int) error
Exampleapp.Get("/not-found", func(c *fiber.Ctx) error {return c.SendStatus(415)// => 415 "Unsupported Media Type"c.SendString("Hello, World!")return c.SendStatus(415)// => 415 "Hello, World!"})
Sets the response’s HTTP header field to the specified key
, value
.
Signaturefunc (c *Ctx) Set(key string, val string)
Exampleapp.Get("/", func(c *fiber.Ctx) error {c.Set("Content-Type", "text/plain")// => "Content-type: text/plain"// ...})
https://expressjs.com/en/4x/api.html#req.stale
Signaturefunc (c *Ctx) Stale() bool
Sets the HTTP status for the response.
Method is a chainable.
Signaturefunc (c *Ctx) Status(status int) *Ctx
Exampleapp.Get("/", func(c *fiber.Ctx) error {c.Status(200)return nilreturn c.Status(400).Send("Bad Request")return c.Status(404).SendFile("./public/gopher.png")})
Returns a string slice of subdomains in the domain name of the request.
The application property subdomain offset, which defaults to 2
, is used for determining the beginning of the subdomain segments.
Signaturefunc (c *Ctx) Subdomains(offset ...int) []string
Example// Host: "tobi.ferrets.example.com"app.Get("/", func(c *fiber.Ctx) error {c.Subdomains() // ["ferrets", "tobi"]c.Subdomains(1) // ["tobi"]// ...})
Sets the Content-Type HTTP header to the MIME type listed here specified by the file extension.
Signaturefunc (c *Ctx) Type(ext string, charset ...string) *Ctx
Exampleapp.Get("/", func(c *fiber.Ctx) error {c.Type(".html") // => "text/html"c.Type("html") // => "text/html"c.Type("png") // => "image/png"c.Type("json", "utf-8") // => "application/json; charset=utf-8"// ...})
Adds the given header field to the Vary response header. This will append the header, if not already listed, otherwise leaves it listed in the current location.
Multiple fields are allowed.
Signaturefunc (c *Ctx) Vary(fields ...string)
Exampleapp.Get("/", func(c *fiber.Ctx) error {c.Vary("Origin") // => Vary: Originc.Vary("User-Agent") // => Vary: Origin, User-Agent// No duplicatesc.Vary("Origin") // => Vary: Origin, User-Agentc.Vary("Accept-Encoding", "Accept")// => Vary: Origin, User-Agent, Accept-Encoding, Accept// ...})
Write adopts the Writer interface
Signaturefunc (c *Ctx) Write(p []byte) (n int, err error)
Exampleapp.Get("/", func(c *fiber.Ctx) error {c.Write([]byte("Hello, World!")) // => "Hello, World!"fmt.Fprintf(c, "%s\n", "Hello, World!") // "Hello, World!Hello, World!"})
A Boolean property, that is true
, if the request’s X-Requested-With header field is XMLHttpRequest, indicating that the request was issued by a client library (such as jQuery).
Signaturefunc (c *Ctx) XHR() bool
Example// X-Requested-With: XMLHttpRequestapp.Get("/", func(c *fiber.Ctx) error {c.XHR() // true// ...})