[std-http] fix-header (#134)

Reviewed-on: https://codeberg.org/Codeberg/pages-server/pulls/134
This commit is contained in:
6543 2022-11-11 06:38:09 +01:00
parent 4117775cf0
commit 7526873049
9 changed files with 72 additions and 75 deletions

View file

@ -10,12 +10,14 @@ import (
type Context struct {
RespWriter http.ResponseWriter
Req *http.Request
StatusCode int
}
func New(w http.ResponseWriter, r *http.Request) *Context {
return &Context{
RespWriter: w,
Req: r,
StatusCode: http.StatusOK,
}
}
@ -27,10 +29,7 @@ func (c *Context) Context() stdContext.Context {
}
func (c *Context) Response() *http.Response {
if c.Req != nil {
if c.Req.Response == nil {
c.Req.Response = &http.Response{Header: make(http.Header)}
}
if c.Req != nil && c.Req.Response != nil {
return c.Req.Response
}
return nil