package context import ( stdContext "context" "net/http" ) type Context struct { RespWriter http.ResponseWriter Req *http.Request } func New(w http.ResponseWriter, r *http.Request) *Context { return &Context{ RespWriter: w, Req: r, } } 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 } func (c *Context) Redirect(uri string, statusCode int) { http.Redirect(c.RespWriter, c.Req, uri, statusCode) } // Path returns requested path. // // The returned bytes are valid until your request handler returns. func (c *Context) Path() string { return c.Req.URL.Path }