feat: add web context and add go net/http web context

This commit is contained in:
weloe
2023-05-02 15:06:54 +08:00
parent 35c206716d
commit c04ab085b4
14 changed files with 1024 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
package go_http_context
import (
"github.com/weloe/token-go/ctx"
"reflect"
)
var _ ctx.Context = (*HttpContext)(nil)
type HttpContext struct {
req ctx.Request
response ctx.Response
reqStorage ctx.ReqStorage
}
func (h *HttpContext) IsValidContext() bool {
return h.req != nil && !reflect.DeepEqual(h.req, &HttpRequest{})
}
func (h *HttpContext) Request() ctx.Request {
return h.req
}
func (h *HttpContext) ReqStorage() ctx.ReqStorage {
return h.reqStorage
}
func (h *HttpContext) Response() ctx.Response {
return h.response
}
func (h *HttpContext) MatchPath(pattern string, path string) bool {
return true
}