more string

This commit is contained in:
6543 2022-08-28 15:33:10 +02:00
parent 32431b23bb
commit 662d76386c
No known key found for this signature in database
GPG key ID: C99B82E40B027BAE
5 changed files with 51 additions and 30 deletions

View file

@ -10,6 +10,13 @@ type Context struct {
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()
@ -27,3 +34,10 @@ func (c *Context) Response() *http.Response {
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
}