mirror of
https://github.com/eolinker/apinto
synced 2025-10-05 08:47:04 +08:00
鉴权部分兼容插件管理器
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
package http_context
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/valyala/fasthttp"
|
||||
|
||||
http_service "github.com/eolinker/eosc/http-service"
|
||||
access_field "github.com/eolinker/goku/node/common/access-field"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
)
|
||||
@@ -24,8 +27,96 @@ type Context struct {
|
||||
bodyHandler *BodyRequestHandler
|
||||
}
|
||||
|
||||
func (ctx *Context) SetStatus(code int, status string) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) Request() http_service.RequestReader {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) ProxyResponse() http_service.ResponseReader {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) Context() context.Context {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) Value(key interface{}) interface{} {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) WithValue(key, val interface{}) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) GetHeader(name string) string {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) Headers() http.Header {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) SetHeader(key, value string) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) AddHeader(key, value string) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) DelHeader(key string) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) Set() http_service.Header {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) Append() http_service.Header {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) Cookie(name string) (*http.Cookie, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) Cookies() []*http.Cookie {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) AddCookie(c *http.Cookie) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) StatusCode() int {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) Status() string {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) GetBody() []byte {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) Proxy() http_service.Request {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) SetStoreValue(key string, value interface{}) error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (ctx *Context) GetStoreValue(key string) (interface{}, bool) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
//NewContext 创建Context
|
||||
func NewContext(ctx *fasthttp.RequestCtx) *Context {
|
||||
func NewContext(ctx *fasthttp.RequestCtx) http_service.IHttpContext {
|
||||
id := uuid.NewV4()
|
||||
requestID := id.String()
|
||||
newRequest := &ctx.Request
|
||||
@@ -70,12 +161,12 @@ func (ctx *Context) RequestId() string {
|
||||
return ctx.requestID
|
||||
}
|
||||
|
||||
func (ctx *Context) Request() IRequest {
|
||||
if ctx.request == nil {
|
||||
ctx.request = newRequest(ctx.requestOrg)
|
||||
}
|
||||
return ctx.request
|
||||
}
|
||||
//func (ctx *Context) Request() IRequest {
|
||||
// if ctx.request == nil {
|
||||
// ctx.request = newRequest(ctx.requestOrg)
|
||||
// }
|
||||
// return ctx.request
|
||||
//}
|
||||
|
||||
func (ctx *Context) RequestOrg() *fasthttp.Request {
|
||||
return ctx.requestOrg
|
||||
@@ -85,14 +176,15 @@ func (ctx *Context) ProxyRequest() *fasthttp.Request {
|
||||
return ctx.proxyRequest
|
||||
}
|
||||
|
||||
func (ctx *Context) ProxyResponse() *fasthttp.Response {
|
||||
return ctx.proxyResponse
|
||||
}
|
||||
//func (ctx *Context) ProxyResponse() *fasthttp.Response {
|
||||
// return ctx.proxyResponse
|
||||
//}
|
||||
|
||||
func (ctx *Context) BodyHandler() *BodyRequestHandler {
|
||||
if ctx.bodyHandler == nil {
|
||||
r := ctx.Request()
|
||||
ctx.bodyHandler = newBodyRequestHandler(r.ContentType(), r.RawBody())
|
||||
body, _ := r.RawBody()
|
||||
ctx.bodyHandler = newBodyRequestHandler(r.ContentType(), body)
|
||||
}
|
||||
return ctx.bodyHandler
|
||||
}
|
||||
|
Reference in New Issue
Block a user