mirror of
https://github.com/weloe/token-go.git
synced 2025-10-06 16:07:18 +08:00
feat: add adapter
This commit is contained in:
@@ -2,6 +2,7 @@ package go_http_context
|
||||
|
||||
import (
|
||||
"github.com/weloe/token-go/ctx"
|
||||
"net/http"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
@@ -13,6 +14,14 @@ type HttpContext struct {
|
||||
reqStorage ctx.ReqStorage
|
||||
}
|
||||
|
||||
func NewHttpContext(req *http.Request, writer http.ResponseWriter) *HttpContext {
|
||||
return &HttpContext{
|
||||
req: NewHttpRequest(req),
|
||||
response: NewResponse(req, writer),
|
||||
reqStorage: NewReqStorage(req),
|
||||
}
|
||||
}
|
||||
|
||||
func (h *HttpContext) IsValidContext() bool {
|
||||
return h.req != nil && !reflect.DeepEqual(h.req, &HttpRequest{})
|
||||
}
|
||||
|
Reference in New Issue
Block a user