http: Add an HTTP redirect senteniel error
This commit is contained in:
parent
bf668b0cf7
commit
efc3fc0990
@ -179,6 +179,12 @@ func (this *Handler) serveDocument (
|
|||||||
this.serveError (
|
this.serveError (
|
||||||
res, req,
|
res, req,
|
||||||
httpError.Status, httpError.Message, false)
|
httpError.Status, httpError.Message, false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var httpRedirect Redirect
|
||||||
|
if errors.As(err, &httpRedirect) {
|
||||||
|
http.Redirect(res, req, httpRedirect.Location, httpRedirect.Status)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.serveError (
|
this.serveError (
|
||||||
|
13
http/http.go
13
http/http.go
@ -22,6 +22,19 @@ func (err Error) Error () string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Redirect, if returned from a template, will cause the server to redirect the
|
||||||
|
// client to the given location.
|
||||||
|
type Redirect struct {
|
||||||
|
Status int
|
||||||
|
Location string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (err Redirect) Error () string {
|
||||||
|
return fmt.Sprintf (
|
||||||
|
"%d: %s: %s",
|
||||||
|
err.Status, http.StatusText(err.Status), err.Location)
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPData represents information about an ongoing HTTP request that is made
|
// HTTPData represents information about an ongoing HTTP request that is made
|
||||||
// available to templates as they are being executed.
|
// available to templates as they are being executed.
|
||||||
type HTTPData struct {
|
type HTTPData struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user