Documentation ¶
Index ¶
- Variables
- func HandleFunc(pattern string, handler func(context.Context, ResponseWriter, *Request))
- func ListenAndServe(addr string, handler Handler, opts ...Option) error
- func NotFound(ctx context.Context, w ResponseWriter, r *Request)
- type ConnState
- type Handler
- type HandlerFunc
- type Logger
- type MiddlewareFunc
- type Option
- type Request
- type ResponseWriter
- type SemaOpt
- type Semaphore
- type ServeMux
- type Server
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ServerContextKey = &contextKey{"redis-server"} LocalAddrContextKey = &contextKey{"local-addr"} ErrServerClosed = errors.New("redis: Server closed") )
View Source
var (
DefaultServeMux = &defaultServeMux
)
Functions ¶
func HandleFunc ¶
func HandleFunc(pattern string, handler func(context.Context, ResponseWriter, *Request))
Types ¶
type ConnState ¶
type ConnState int
const ( // StateNew represents a new connection that is expected to // send a request immediately. Connections begin at this // state and then transition to either StateActive or // StateClosed. StateNew ConnState = iota // StateActive represents a connection that has read 1 or more // bytes of a request. The Server.ConnState hook for // StateActive fires before the request has entered a handler // and doesn't fire again until the request has been // handled. After the request is handled, the state // transitions to StateClosed, StateHijacked, or StateIdle. // For HTTP/2, StateActive fires on the transition from zero // to one active request, and only transitions away once all // active requests are complete. That means that ConnState // cannot be used to do per-request work; ConnState only notes // the overall state of the connection. StateActive // StateIdle represents a connection that has finished // handling a request and is in the keep-alive state, waiting // for a new request. Connections transition from StateIdle // to either StateActive or StateClosed. StateIdle // StateHijacked represents a hijacked connection. // This is a terminal state. It does not transition to StateClosed. StateHijacked // StateClosed represents a closed connection. // This is a terminal state. Hijacked connections do not // transition to StateClosed. StateClosed )
type Handler ¶
type Handler interface {
ServeRedis(context.Context, ResponseWriter, *Request)
}
func NotFoundHandler ¶
func NotFoundHandler() Handler
type HandlerFunc ¶
type HandlerFunc func(context.Context, ResponseWriter, *Request)
func MergeMiddleware ¶
func MergeMiddleware(fn HandlerFunc, middlewares ...MiddlewareFunc) HandlerFunc
func (HandlerFunc) ServeRedis ¶
func (f HandlerFunc) ServeRedis(ctx context.Context, w ResponseWriter, r *Request)
type MiddlewareFunc ¶
type MiddlewareFunc func(HandlerFunc) HandlerFunc
type Option ¶
type Option func(*option)
func WithLoggerFactory ¶
func WithPanicStack ¶
func WithSemaphore ¶
type ResponseWriter ¶
type SemaOpt ¶
type SemaOpt func(*semaOpt)
func WithWaitDura ¶
if block is false, this config should not be used
type ServeMux ¶
type ServeMux struct {
// contains filtered or unexported fields
}
func (*ServeMux) HandleFunc ¶
func (mux *ServeMux) HandleFunc(pattern string, handler func(context.Context, ResponseWriter, *Request), middlewares ...MiddlewareFunc)
func (*ServeMux) ServeRedis ¶
func (mux *ServeMux) ServeRedis(ctx context.Context, w ResponseWriter, r *Request)
Click to show internal directories.
Click to hide internal directories.