Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultProvider() httpsession.SessionProvider
- func GetSession(req *Request) httpsession.Session
- func NewEndPoint(name string, task HandlerTask, acceptances []Acceptance) *_EndPoint
- func NewGroup(name string, acceptances []Acceptance) *_RouteGroup
- type Acceptance
- type Channel
- type DefaultAcceptanceInterrupt
- type DefaultHTTPHandlerTask
- func (h *DefaultHTTPHandlerTask) After(req *Request, resp *Response, params map[string]interface{}) ErrorResponse
- func (h *DefaultHTTPHandlerTask) Before(req *Request, resp *Response, params map[string]interface{}) ErrorResponse
- func (h *DefaultHTTPHandlerTask) Connect(ctx channel.HandlerContext, req *Request, resp *Response, ...) ErrorResponse
- func (h *DefaultHTTPHandlerTask) Delete(ctx channel.HandlerContext, req *Request, resp *Response, ...) ErrorResponse
- func (h *DefaultHTTPHandlerTask) ErrorCaught(req *Request, resp *Response, params map[string]interface{}, err ErrorResponse) error
- func (h *DefaultHTTPHandlerTask) Get(ctx channel.HandlerContext, req *Request, resp *Response, ...) ErrorResponse
- func (h *DefaultHTTPHandlerTask) Index(ctx channel.HandlerContext, req *Request, resp *Response, ...) ErrorResponse
- func (h *DefaultHTTPHandlerTask) Options(ctx channel.HandlerContext, req *Request, resp *Response, ...) ErrorResponse
- func (h *DefaultHTTPHandlerTask) Patch(ctx channel.HandlerContext, req *Request, resp *Response, ...) ErrorResponse
- func (h *DefaultHTTPHandlerTask) Post(ctx channel.HandlerContext, req *Request, resp *Response, ...) ErrorResponse
- func (h *DefaultHTTPHandlerTask) PreCheck(req *Request, resp *Response, params map[string]interface{}) ErrorResponse
- func (h *DefaultHTTPHandlerTask) Put(ctx channel.HandlerContext, req *Request, resp *Response, ...) ErrorResponse
- func (h *DefaultHTTPHandlerTask) ThrowErrorResponse(err ErrorResponse)
- func (h *DefaultHTTPHandlerTask) Trace(ctx channel.HandlerContext, req *Request, resp *Response, ...) ErrorResponse
- type DefaultHandlerTask
- func (h *DefaultHandlerTask) GetID(name string, params map[string]interface{}) string
- func (h *DefaultHandlerTask) GetNodeName(params map[string]interface{}) string
- func (h *DefaultHandlerTask) IsIndex(params map[string]interface{}) bool
- func (h *DefaultHandlerTask) LogExtend(key string, value interface{}, params map[string]interface{})
- type DefaultRoute
- func (r *DefaultRoute) AddEndPoint(point *_EndPoint) *DefaultRoute
- func (r *DefaultRoute) AddGroup(group *_RouteGroup) *DefaultRoute
- func (r *DefaultRoute) AddRecursivePoint(point *_EndPoint) *DefaultRoute
- func (r *DefaultRoute) RouteEndPoint(req *Request) (node RouteNode, nodeParams map[string]interface{}, isLast bool)
- func (r *DefaultRoute) SetRoot(point *_EndPoint) *DefaultRoute
- type DispatchAcceptance
- func (a *DispatchAcceptance) Do(req *Request, resp *Response, params map[string]interface{}) error
- func (a *DispatchAcceptance) GetID(name string, params map[string]interface{}) string
- func (a *DispatchAcceptance) GetNodeName(params map[string]interface{}) string
- func (a *DispatchAcceptance) IsIndex(params map[string]interface{}) string
- func (a *DispatchAcceptance) LogExtend(key string, value interface{}, params map[string]interface{})
- type DispatchHandler
- type ErrorResponse
- type ErrorResponseImpl
- type GZipHandler
- type HandlerTask
- type HttpHandlerTask
- type HttpTask
- type LanguageValue
- type LogHandler
- type LogStruct
- type ObjectLogStruct
- type Pack
- type QualityValue
- type ReadRequestLogStruct
- type Request
- func (r *Request) Accept() []QualityValue
- func (r *Request) AcceptCharset() []QualityValue
- func (r *Request) AcceptEncoding() []QualityValue
- func (r *Request) AcceptLanguage() []LanguageValue
- func (r *Request) AddCookie(c *http.Cookie)
- func (r *Request) Body() buf.ByteBuf
- func (r *Request) Channel() channel.Channel
- func (r *Request) ContentLength() int64
- func (r *Request) Cookie(name string) (*http.Cookie, error)
- func (r *Request) Cookies() []*http.Cookie
- func (r *Request) CreatedAt() *time.Time
- func (r *Request) FormFile(key string) (multipart.File, *multipart.FileHeader, error)
- func (r *Request) FormValue(key string) string
- func (r *Request) Header() http.Header
- func (r *Request) Host() string
- func (r *Request) Method() string
- func (r *Request) Origin() string
- func (r *Request) PreferLang() *language.Tag
- func (r *Request) Proto() string
- func (r *Request) Referer() string
- func (r *Request) RemoteAddr() (ip net.IP, port string)
- func (r *Request) RemoteAddrs() []string
- func (r *Request) RemoteIP() (ip net.IP)
- func (r *Request) RenewSession()
- func (r *Request) Request() *http.Request
- func (r *Request) RequestURI() string
- func (r *Request) Session() httpsession.Session
- func (r *Request) TE() []QualityValue
- func (r *Request) TrackID() string
- func (r *Request) Url() *url.URL
- func (r *Request) UserAgent() string
- type RequestLogStruct
- type Response
- func (r *Response) AddHeader(name string, value string) *Response
- func (r *Response) Body() []byte
- func (r *Response) Cookie(name string) *http.Cookie
- func (r *Response) Cookies() map[string][]http.Cookie
- func (r *Response) DelHeader(name string) *Response
- func (r *Response) GetHeader(name string) string
- func (r *Response) Header() http.Header
- func (r *Response) JsonResponse(obj interface{})
- func (r *Response) Redirect(redirectUrl string)
- func (r *Response) Request() *Request
- func (r *Response) ResponseError(er ErrorResponse)
- func (r *Response) SetBody(buf buf.ByteBuf)
- func (r *Response) SetContentType(ct string)
- func (r *Response) SetCookie(cookie *http.Cookie) *Response
- func (r *Response) SetHeader(name string, value string) *Response
- func (r *Response) SetStatusCode(statusCode int) *Response
- func (r *Response) StatusCode() int
- func (r *Response) TextResponse(buf buf.ByteBuf)
- type ResponseLogStruct
- type ResponseWriter
- type ReturnCatch
- type Route
- type RouteNode
- type RouteType
- type ServerChannel
- type SessionType
- type StaticFilesHandlerTask
Constants ¶
View Source
const ConnChCtx = "conn_ch"
View Source
const ConnCtx = "conn"
View Source
const MaxMultiPartMemory = 1024 * 1024 * 256
Variables ¶
View Source
var AcceptanceInterrupt = &DefaultAcceptanceInterrupt{}
View Source
var DefaultSessionType = SessionTypeMemory
View Source
var NotImplemented = erresponse.NotImplemented
View Source
var ParamAcceptWaitCount channel.ParamKey = "accept_wait_count"
View Source
var ParamIdleTimeout channel.ParamKey = "idle_timeout"
View Source
var ParamMaxHeaderBytes channel.ParamKey = "max_header_bytes"
View Source
var ParamMaxMultiPartMemory channel.ParamKey = "max_multi_part_memory"
View Source
var ParamReadHeaderTimeout channel.ParamKey = "read_header_timeout"
View Source
var ParamReadTimeout channel.ParamKey = "read_timeout"
View Source
var ParamWriteTimeout channel.ParamKey = "write_timeout"
View Source
var SessionDomain = ""
View Source
var SessionExpireTime = 86400
View Source
var SessionHttpOnly = false
View Source
var SessionKey = "KKLAB"
View Source
var SessionSecure = false
Functions ¶
func DefaultProvider ¶
func DefaultProvider() httpsession.SessionProvider
func GetSession ¶
func GetSession(req *Request) httpsession.Session
func NewEndPoint ¶
func NewEndPoint(name string, task HandlerTask, acceptances []Acceptance) *_EndPoint
func NewGroup ¶
func NewGroup(name string, acceptances []Acceptance) *_RouteGroup
Types ¶
type Acceptance ¶
type Channel ¶
type Channel struct {
channel.DefaultNetChannel
}
func (*Channel) UnsafeIsAutoRead ¶
func (*Channel) UnsafeRead ¶
func (*Channel) UnsafeWrite ¶
type DefaultAcceptanceInterrupt ¶
type DefaultAcceptanceInterrupt struct { }
func (DefaultAcceptanceInterrupt) Error ¶
func (DefaultAcceptanceInterrupt) Error() string
type DefaultHTTPHandlerTask ¶
type DefaultHTTPHandlerTask struct {
DefaultHandlerTask
}
func (*DefaultHTTPHandlerTask) After ¶
func (h *DefaultHTTPHandlerTask) After(req *Request, resp *Response, params map[string]interface{}) ErrorResponse
func (*DefaultHTTPHandlerTask) Before ¶
func (h *DefaultHTTPHandlerTask) Before(req *Request, resp *Response, params map[string]interface{}) ErrorResponse
func (*DefaultHTTPHandlerTask) Connect ¶
func (h *DefaultHTTPHandlerTask) Connect(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse
func (*DefaultHTTPHandlerTask) Delete ¶
func (h *DefaultHTTPHandlerTask) Delete(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse
func (*DefaultHTTPHandlerTask) ErrorCaught ¶
func (h *DefaultHTTPHandlerTask) ErrorCaught(req *Request, resp *Response, params map[string]interface{}, err ErrorResponse) error
func (*DefaultHTTPHandlerTask) Get ¶
func (h *DefaultHTTPHandlerTask) Get(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse
func (*DefaultHTTPHandlerTask) Index ¶
func (h *DefaultHTTPHandlerTask) Index(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse
func (*DefaultHTTPHandlerTask) Options ¶
func (h *DefaultHTTPHandlerTask) Options(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse
func (*DefaultHTTPHandlerTask) Patch ¶
func (h *DefaultHTTPHandlerTask) Patch(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse
func (*DefaultHTTPHandlerTask) Post ¶
func (h *DefaultHTTPHandlerTask) Post(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse
func (*DefaultHTTPHandlerTask) PreCheck ¶
func (h *DefaultHTTPHandlerTask) PreCheck(req *Request, resp *Response, params map[string]interface{}) ErrorResponse
func (*DefaultHTTPHandlerTask) Put ¶
func (h *DefaultHTTPHandlerTask) Put(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse
func (*DefaultHTTPHandlerTask) ThrowErrorResponse ¶
func (h *DefaultHTTPHandlerTask) ThrowErrorResponse(err ErrorResponse)
func (*DefaultHTTPHandlerTask) Trace ¶
func (h *DefaultHTTPHandlerTask) Trace(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse
type DefaultHandlerTask ¶
type DefaultHandlerTask struct { }
func NewDefaultHandlerTask ¶
func NewDefaultHandlerTask() *DefaultHandlerTask
func (*DefaultHandlerTask) GetID ¶
func (h *DefaultHandlerTask) GetID(name string, params map[string]interface{}) string
func (*DefaultHandlerTask) GetNodeName ¶
func (h *DefaultHandlerTask) GetNodeName(params map[string]interface{}) string
func (*DefaultHandlerTask) IsIndex ¶
func (h *DefaultHandlerTask) IsIndex(params map[string]interface{}) bool
func (*DefaultHandlerTask) LogExtend ¶
func (h *DefaultHandlerTask) LogExtend(key string, value interface{}, params map[string]interface{})
type DefaultRoute ¶
type DefaultRoute struct {
// contains filtered or unexported fields
}
func NewRoute ¶
func NewRoute() *DefaultRoute
func (*DefaultRoute) AddEndPoint ¶
func (r *DefaultRoute) AddEndPoint(point *_EndPoint) *DefaultRoute
func (*DefaultRoute) AddGroup ¶
func (r *DefaultRoute) AddGroup(group *_RouteGroup) *DefaultRoute
func (*DefaultRoute) AddRecursivePoint ¶
func (r *DefaultRoute) AddRecursivePoint(point *_EndPoint) *DefaultRoute
func (*DefaultRoute) RouteEndPoint ¶
func (r *DefaultRoute) RouteEndPoint(req *Request) (node RouteNode, nodeParams map[string]interface{}, isLast bool)
func (*DefaultRoute) SetRoot ¶
func (r *DefaultRoute) SetRoot(point *_EndPoint) *DefaultRoute
type DispatchAcceptance ¶
type DispatchAcceptance struct { }
func (*DispatchAcceptance) Do ¶
func (a *DispatchAcceptance) Do(req *Request, resp *Response, params map[string]interface{}) error
func (*DispatchAcceptance) GetID ¶
func (a *DispatchAcceptance) GetID(name string, params map[string]interface{}) string
func (*DispatchAcceptance) GetNodeName ¶
func (a *DispatchAcceptance) GetNodeName(params map[string]interface{}) string
func (*DispatchAcceptance) IsIndex ¶
func (a *DispatchAcceptance) IsIndex(params map[string]interface{}) string
func (*DispatchAcceptance) LogExtend ¶
func (a *DispatchAcceptance) LogExtend(key string, value interface{}, params map[string]interface{})
type DispatchHandler ¶
type DispatchHandler struct { channel.DefaultHandler DefaultStatusCode int DefaultStatusResponse map[int]func(req *Request, resp *Response, params map[string]interface{}) // contains filtered or unexported fields }
func NewDispatchHandler ¶
func NewDispatchHandler(route Route) *DispatchHandler
func (*DispatchHandler) ErrorCaught ¶
func (h *DispatchHandler) ErrorCaught(ctx channel.HandlerContext, err error)
func (*DispatchHandler) Read ¶
func (h *DispatchHandler) Read(ctx channel.HandlerContext, obj interface{})
type ErrorResponse ¶
type ErrorResponse interface { erresponse.ErrorResponse }
type ErrorResponseImpl ¶
type ErrorResponseImpl struct { erresponse.ErrorResponse Caught *kkpanic.CaughtImpl `json:"caught,omitempty"` }
func (*ErrorResponseImpl) String ¶
func (e *ErrorResponseImpl) String() string
type GZipHandler ¶
type GZipHandler struct { channel.DefaultHandler CompressThreshold int }
func (*GZipHandler) Added ¶
func (h *GZipHandler) Added(ctx channel.HandlerContext)
func (*GZipHandler) Write ¶
func (h *GZipHandler) Write(ctx channel.HandlerContext, obj interface{}, future channel.Future)
type HandlerTask ¶
type HttpHandlerTask ¶
type HttpHandlerTask interface { HttpTask PreCheck(req *Request, resp *Response, params map[string]interface{}) ErrorResponse Before(req *Request, resp *Response, params map[string]interface{}) ErrorResponse After(req *Request, resp *Response, params map[string]interface{}) ErrorResponse ErrorCaught(req *Request, resp *Response, params map[string]interface{}, err ErrorResponse) error }
type HttpTask ¶
type HttpTask interface { Index(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse Get(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse Post(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse Put(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse Delete(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse Options(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse Patch(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse Trace(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse Connect(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse }
type LanguageValue ¶
type LogHandler ¶
type LogHandler struct { channel.DefaultHandler FilterFunc func(req *Request, resp *Response, params map[string]interface{}) bool // contains filtered or unexported fields }
func NewLogHandler ¶
func NewLogHandler(printBody bool) *LogHandler
func (*LogHandler) Read ¶
func (h *LogHandler) Read(ctx channel.HandlerContext, obj interface{})
func (*LogHandler) Write ¶
func (h *LogHandler) Write(ctx channel.HandlerContext, obj interface{}, future channel.Future)
type LogStruct ¶
type LogStruct struct { ChannelID string `json:"cid,omitempty"` TrackID string `json:"tid,omitempty"` Method string `json:"method,omitempty"` URI string `json:"uri,omitempty"` StatusCode int `json:"status_code,omitempty"` RemoteAddr string `json:"remote_addr,omitempty"` RemoteAddrs string `json:"remote_addrs,omitempty"` Request *RequestLogStruct `json:"request,omitempty"` Response *ResponseLogStruct `json:"response,omitempty"` AcceptTime int64 `json:"accept_time,omitempty"` HLocateTime int64 `json:"h_locate_time,omitempty"` HAcceptanceTime int64 `json:"h_acceptance_time,omitempty"` HandlerTime int64 `json:"handler_time,omitempty"` HErrorTime int64 `json:"h_error_time,omitempty"` CompressTime int64 `json:"compress_time,omitempty"` ProcessTime int64 `json:"process_time,omitempty"` Extend interface{} `json:"extend,omitempty"` }
type ObjectLogStruct ¶
type ObjectLogStruct struct { ChannelID string `json:"cid,omitempty"` TrackID string `json:"tid,omitempty"` State string `json:"state,omitempty"` Handler string `json:"handler,omitempty"` URI string `json:"uri,omitempty"` Message interface{} `json:"message,omitempty"` RemoteAddr string `json:"remote_addr,omitempty"` }
type Pack ¶
type Pack struct { Request *Request `json:"request"` Response *Response `json:"response"` RouteNode RouteNode `json:"route_node"` Params map[string]interface{} `json:"params"` Writer ResponseWriter `json:"writer"` }
type QualityValue ¶
type ReadRequestLogStruct ¶
type ReadRequestLogStruct struct { ChannelID string `json:"cid,omitempty"` TrackID string `json:"tid,omitempty"` RemoteAddr string `json:"remote_addr,omitempty"` RemoteAddrs string `json:"remote_addrs,omitempty"` Request *RequestLogStruct `json:"request"` }
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func (*Request) Accept ¶
func (r *Request) Accept() []QualityValue
func (*Request) AcceptCharset ¶
func (r *Request) AcceptCharset() []QualityValue
func (*Request) AcceptEncoding ¶
func (r *Request) AcceptEncoding() []QualityValue
func (*Request) AcceptLanguage ¶
func (r *Request) AcceptLanguage() []LanguageValue
func (*Request) ContentLength ¶
func (*Request) PreferLang ¶
func (*Request) RemoteAddrs ¶
func (*Request) RenewSession ¶
func (r *Request) RenewSession()
func (*Request) RequestURI ¶
func (*Request) Session ¶
func (r *Request) Session() httpsession.Session
func (*Request) TE ¶
func (r *Request) TE() []QualityValue
type RequestLogStruct ¶
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func EmptyResponse ¶
func EmptyResponse() *Response
func NewResponse ¶
func WrapResponse ¶
func WrapResponse(ch channel.NetChannel, response *http.Response) *Response
func (*Response) JsonResponse ¶
func (r *Response) JsonResponse(obj interface{})
func (*Response) ResponseError ¶
func (r *Response) ResponseError(er ErrorResponse)
func (*Response) SetContentType ¶
func (*Response) SetStatusCode ¶
func (*Response) StatusCode ¶
func (*Response) TextResponse ¶
type ResponseLogStruct ¶
type ResponseLogStruct struct { URI string `json:"uri,omitempty"` StatusCode int `json:"status_code,omitempty"` Headers map[string]interface{} `json:"headers,omitempty"` Body string `json:"body,omitempty"` OutBodyLength int `json:"out_body_length,omitempty"` PreCompressLength int `json:"pre_compress_length,omitempty"` }
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter }
type ReturnCatch ¶
type ReturnCatch struct {
// contains filtered or unexported fields
}
type RouteNode ¶
type RouteNode interface { Parent() RouteNode HandlerTask() HandlerTask Name() string AggregatedAcceptances() []Acceptance Acceptances() []Acceptance Resources() map[string]RouteNode RouteType() RouteType }
type ServerChannel ¶
type ServerChannel struct { channel.DefaultNetServerChannel // contains filtered or unexported fields }
func (*ServerChannel) IsActive ¶
func (c *ServerChannel) IsActive() bool
func (*ServerChannel) ServeHTTP ¶
func (c *ServerChannel) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*ServerChannel) UnsafeAccept ¶
func (c *ServerChannel) UnsafeAccept() (channel.Channel, channel.Future)
func (*ServerChannel) UnsafeBind ¶
func (c *ServerChannel) UnsafeBind(localAddr net.Addr) error
func (*ServerChannel) UnsafeClose ¶
func (c *ServerChannel) UnsafeClose() error
type SessionType ¶
type SessionType string
const SessionTypeMemory SessionType = "MEMORY"
const SessionTypeRedis SessionType = "REDIS"
type StaticFilesHandlerTask ¶
type StaticFilesHandlerTask struct { DefaultHTTPHandlerTask FolderPath string DoMinify bool DoCache bool // contains filtered or unexported fields }
func NewStaticFilesHandlerTask ¶
func NewStaticFilesHandlerTask(folderPath string) *StaticFilesHandlerTask
func (*StaticFilesHandlerTask) Get ¶
func (h *StaticFilesHandlerTask) Get(ctx channel.HandlerContext, req *Request, resp *Response, params map[string]interface{}) ErrorResponse
Source Files
¶
Click to show internal directories.
Click to hide internal directories.