mirror of
https://github.com/gofiber/fiber.git
synced 2025-02-24 11:24:05 +00:00
Update doc
This commit is contained in:
parent
e9a4f6e360
commit
6616af0125
@ -193,8 +193,8 @@ c.Fasthttp...
|
||||
|
||||
// Example
|
||||
app.Get("/", func(c *fiber.Ctx) {
|
||||
string(c.Fasthttp.Request.Header.Method())
|
||||
// => "GET"
|
||||
c.Fasthttp.Request.Header.Method()
|
||||
// => []byte("GET")
|
||||
|
||||
c.Fasthttp.Response.Write([]byte("Hello, World!"))
|
||||
// => "Hello, World!"
|
||||
@ -360,8 +360,8 @@ Sends a JSON response with JSONP support. This method is identical to [Json()](#
|
||||
By default, the JSONP callback name is simply callback. Override this by passing a named string in the function.
|
||||
```go
|
||||
// Function signature
|
||||
c.Jsonp(json interface{}) error
|
||||
c.Jsonp(callback string, v interface{}) error
|
||||
c.Jsonp(v interface{}) error
|
||||
c.Jsonp(v interface{}, callback string) error
|
||||
// Example
|
||||
type JsonStruct struct {
|
||||
name string
|
||||
@ -377,7 +377,7 @@ app.Get("/", func(c *fiber.Ctx) {
|
||||
c.Jsonp(data)
|
||||
// => callback({"name": "Grame", "age": 20})
|
||||
|
||||
c.Jsonp("customFunc", data)
|
||||
c.Jsonp(data, "customFunc")
|
||||
// => customFunc({"name": "Grame", "age": 20})
|
||||
})
|
||||
app.Listen(8080)
|
||||
@ -552,14 +552,14 @@ Redirects to the URL derived from the specified path, with specified status, a p
|
||||
```go
|
||||
// Function signature
|
||||
c.Redirect(path string)
|
||||
c.Redirect(status int, path string)
|
||||
c.Redirect(path string, status int)
|
||||
|
||||
// Example
|
||||
app.Get("/", func(c *fiber.Ctx) {
|
||||
c.Redirect("/foo/bar")
|
||||
c.Redirect("http://example.com")
|
||||
c.Redirect(301, "http://example.com")
|
||||
c.Redirect("../login")
|
||||
c.Redirect("http://example.com")
|
||||
c.Redirect("http://example.com", 301)
|
||||
})
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user