mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-25 14:26:58 +00:00
[std-http] fix-header (#134)
Reviewed-on: https://codeberg.org/Codeberg/pages-server/pulls/134
This commit is contained in:
parent
4117775cf0
commit
7526873049
9 changed files with 72 additions and 75 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue