Documentation
¶
Index ¶
- Constants
- func GetRequestContext(rctx Context) (*edgepb.Context, bool)
- func GetRequestTime(ctx context.Context) time.Time
- func SetRequestTime(ctx context.Context) context.Context
- type Context
- type RequestContext
- type RequestHandler
- type ResponseWriter
- type ReverseProxy
- type SentinezContextKey
- type Server
Constants ¶
View Source
const ( HeaderServer = "Server" HeaderXRequestId = "X-Request-Id" HeaderContentType = "Content-Type" HeaderUpgrade = "Upgrade" HeaderUserAgent = "User-Agent" HeaderXForwardedFor = "X-Forwarded-For" HeaderXRealIP = "X-Real-IP" HeaderCacheControl = "Cache-Control" ValueNotFound = "Not found" ValueInternalServerError = "Internal server error" ValueAccessDenied = "Access denied" ValueTextPlain = "text/plain; charset=utf-8" ValueTextHTML = "text/html; charset=utf-8" ValueAppJSON = "application/json; charset=utf-8" SchemeSecure = "https" SchemeInsecure = "http" )
Variables ¶
This section is empty.
Functions ¶
func GetRequestContext ¶
GetRequestContext returns the context value.
Types ¶
type Context ¶
type Context interface {
RequestContext
ResponseWriter
Unwrap() any
Extra() *edgepb.Context
SetExtra(x *edgepb.Context)
Upgrade() (*websocket.Conn, error)
Render(statusCode int, component templ.Component) error
RequestBodyStream() io.Reader
VisitRequestHeaders(visitor func(k, v []byte))
VisitResponseHeaders(visitor func(k, v []byte))
}
type RequestContext ¶
type RequestContext interface {
Context() context.Context
Headers() map[string]string
Queries() map[string][]string
Query(k string) string
QueryStr() string
Header(k string) string
Path() string
URI() string
Body() []byte
JA4() string
TLS() bool
Method() string
Host() string
StatusCode() int
Protocol() string
Scheme() string
RemoteAddr() string
RequestIP() string
RequestId() string
RequestTime() time.Time
SetHeader(key, value string)
SetQuery(key string, values ...string)
SetPath(p string)
SetURI(u string)
SetBody(b []byte)
SetRequestId(id string)
SetRequestIP(ip string)
SetJA4(fingerprint string)
SetMethod(m string)
SetHost(h string)
SetStatusCode(code int)
SetProtocol(p string)
SetRemoteAddr(addr string)
}
type RequestHandler ¶
type ResponseWriter ¶
type ResponseWriter interface {
ResponseHeader() map[string]string
ResponseBody() []byte
SetResponseHeader(key, value string)
AddResponseHeader(key, value string)
ResetResponse()
String(statusCode int, msg string) error
JSON(statusCode int, body []byte) error
File(path string) error
Flush() error
Copy(src io.Reader) error
}
type ReverseProxy ¶
type ReverseProxy interface {
Serve(ctx Context)
}
type SentinezContextKey ¶
type SentinezContextKey string
SentinezContextKey is the key type for the context.
const ( RequestHTTPCtxKey SentinezContextKey = "senz.ctx.request.http" RequestHTTPTimeKey SentinezContextKey = "senz.ctx.request.time" )
type Server ¶
type Server interface {
Shutdown(ctx context.Context) error
ListenAndServe(addr string) error
Use(mdw ...func(next RequestHandler) RequestHandler)
Handle(fn RequestHandler)
ListenAndServeTLS(addr, certFile, keyFile string) error
}
Click to show internal directories.
Click to hide internal directories.