pages-server/server/context/context.go

30 lines
496 B
Go
Raw Normal View History

2022-07-27 15:25:08 +00:00
package context
import (
stdContext "context"
"net/http"
)
type Context struct {
RespWriter http.ResponseWriter
Req *http.Request
}
func (c *Context) Context() stdContext.Context {
if c.Req != nil {
return c.Req.Context()
}
return stdContext.Background()
}
func (c *Context) Response() *http.Response {
if c.Req != nil {
return c.Req.Response
}
return nil
}
2022-08-28 13:09:54 +00:00
func (c *Context) Redirect(uri string, statusCode int) {
http.Redirect(c.RespWriter, c.Req, uri, statusCode)
}