Redirect redirects the request to a provided URL with status code.
(code int, url string)
| 730 | |
| 731 | // Redirect redirects the request to a provided URL with status code. |
| 732 | func (c *Context) Redirect(code int, url string) error { |
| 733 | if code < 300 || code > 308 { |
| 734 | return ErrInvalidRedirectCode |
| 735 | } |
| 736 | c.response.Header().Set(HeaderLocation, url) |
| 737 | c.response.WriteHeader(code) |
| 738 | return nil |
| 739 | } |
| 740 | |
| 741 | // Logger returns logger in Context |
| 742 | func (c *Context) Logger() *slog.Logger { |