mirror of
https://github.com/gin-gonic/gin.git
synced 2026-04-30 07:38:15 +08:00
Merge 0fd0eab2e98d2bd3b2e14d1891b7e5ec1803b7ef into d3ffc9985281dcf4d3bef604cce4e662b1a327a6
This commit is contained in:
commit
b3beba780b
1
mode.go
1
mode.go
@ -55,6 +55,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetMode sets gin mode according to input string.
|
// SetMode sets gin mode according to input string.
|
||||||
|
// It panics if the value is not a valid gin mode (debug, release, or test).
|
||||||
func SetMode(value string) {
|
func SetMode(value string) {
|
||||||
if value == "" {
|
if value == "" {
|
||||||
if flag.Lookup("test.v") != nil {
|
if flag.Lookup("test.v") != nil {
|
||||||
|
|||||||
@ -17,6 +17,7 @@ type Redirect struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render (Redirect) redirects the http request to new location and writes redirect response.
|
// Render (Redirect) redirects the http request to new location and writes redirect response.
|
||||||
|
// It panics if the status code is not a valid redirect status code (300-308, except 201).
|
||||||
func (r Redirect) Render(w http.ResponseWriter) error {
|
func (r Redirect) Render(w http.ResponseWriter) error {
|
||||||
if (r.Code < http.StatusMultipleChoices || r.Code > http.StatusPermanentRedirect) && r.Code != http.StatusCreated {
|
if (r.Code < http.StatusMultipleChoices || r.Code > http.StatusPermanentRedirect) && r.Code != http.StatusCreated {
|
||||||
panic(fmt.Sprintf("Cannot redirect with status code %d", r.Code))
|
panic(fmt.Sprintf("Cannot redirect with status code %d", r.Code))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user