Documentation ¶
Index ¶
- Constants
- Variables
- func DefineStatusLine(status int, statusText string)
- func GetStatusLine(status int) []byte
- func ListenAndServe(addr string, handler Handler) error
- func ListenAndServePrefork(addr string, handler Handler) error
- func ListenAndServeReusePort(addr string, handler Handler) error
- func PreforkChildID() (int, error)
- func PreforkIsChild() bool
- func PutRequestContext(ctx *Context)
- func PutXWWWFormURLEncoded(x *XWWWFormURLEncoded)
- type ChunkedBodyWriter
- type Context
- func (r *Context) BindHeader(v any) error
- func (r *Context) BindJSON(v any) error
- func (r *Context) BindQuery(v any) error
- func (r *Context) BindWWWFormURLEncoded(v any) error
- func (r *Context) Body() ([]byte, error)
- func (r *Context) BodyReader() *h1.BodyReader
- func (r *Context) ChunkedBodyWriter() ChunkedBodyWriter
- func (r *Context) CloseBodyReader()
- func (r *Context) ConnID() uint64
- func (r *Context) ConnectionClose()
- func (r *Context) FastBodyUnsafe(maxBufferSize int64) ([]byte, error)
- func (r *Context) Flush() error
- func (r *Context) GetQueryParam(name []byte) ([]byte, error)
- func (r *Context) GetQueryParamString(name string) (string, error)
- func (r *Context) HijackConn() (bufR h1.HijackReader, bufW *h1.Response, conn net.Conn)
- func (r *Context) Host() string
- func (r *Context) HostBytes() []byte
- func (r *Context) KillConn() error
- func (r *Context) Method() h1.Method
- func (r *Context) MultipartReader() (*multipart.Reader, error)
- func (r *Context) Path() []byte
- func (r *Context) QueryParams() []h1.Query
- func (r *Context) RawURI() []byte
- func (r *Context) ReadJSON(v any) error
- func (r *Context) Redirect(status int, url string)
- func (r *Context) RemoteAddr() net.Addr
- func (r *Context) RequestHeaders() RequestHeaders
- func (r *Context) ResponseHeaders() ResponseHeaders
- func (r *Context) ServerSentEventWriter() ServerSentEventWriter
- func (r *Context) SetContentLength(length int)
- func (r *Context) UpgradeWebSocket(op ws.OpCode) (brwc io.ReadWriteCloser, err error)
- func (r *Context) Write(p []byte) (n int, err error)
- func (r *Context) WriteFullBody(status int, body []byte) error
- func (r *Context) WriteFullBodyString(status int, body string) error
- func (r *Context) WriteHeader(status int)
- func (r *Context) WriteJSON(status int, v any) error
- func (r *Context) WriteJSONIndent(status int, v any, prefix string, indent string) error
- func (r *Context) WriteJSONStream(status int, v any) error
- func (r *Context) WriteStream(status int, stream io.Reader) error
- func (r *Context) WriteString(s string) (n int, err error)
- func (r *Context) XWWWFormURLEncoded(maxSize int64) (*XWWWFormURLEncoded, error)
- type Handler
- type Header
- type KV
- type Method
- type RequestHeaders
- type Response
- type ResponseHeaders
- type Server
- type ServerSentEventWriter
- type XWWWFormURLEncoded
Constants ¶
View Source
const ( ServerStoped uint8 = iota ServerStarting ServerRunning ServerStopping )
View Source
const ( MethodGET = h1.MethodGET MethodHEAD = h1.MethodHEAD MethodPOST = h1.MethodPOST MethodPUT = h1.MethodPUT MethodDELETE = h1.MethodDELETE MethodCONNECT = h1.MethodCONNECT MethodOPTIONS = h1.MethodOPTIONS MethodTRACE = h1.MethodTRACE MethodPATCH = h1.MethodPATCH MethodBREW = h1.MethodBREW )
Variables ¶
View Source
var ErrBindPtrError = errors.New("bind function's parameter must be a pointer")
View Source
var ErrBindType = errors.New("bind type error")
View Source
var ErrBodyTooLarge = errors.New("body too large")
View Source
var ErrContentTypeInvalid = errors.New("content-type invalid")
View Source
var ErrPreforkChildIDNotFound = errors.New("child id not found")
View Source
var ErrUpgradeBadRequest = errors.New("upgrade request is not valid")
Functions ¶
func DefineStatusLine ¶
func GetStatusLine ¶
func ListenAndServe ¶
func ListenAndServePrefork ¶
func ListenAndServeReusePort ¶
func PreforkChildID ¶
func PreforkIsChild ¶
func PreforkIsChild() bool
func PutRequestContext ¶
func PutRequestContext(ctx *Context)
func PutXWWWFormURLEncoded ¶
func PutXWWWFormURLEncoded(x *XWWWFormURLEncoded)
Types ¶
type ChunkedBodyWriter ¶
type ChunkedBodyWriter struct {
// contains filtered or unexported fields
}
func (ChunkedBodyWriter) Close ¶
func (c ChunkedBodyWriter) Close() error
func (ChunkedBodyWriter) WriteString ¶
func (c ChunkedBodyWriter) WriteString(p string) (int, error)
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func GetRequestContext ¶
func (*Context) BindHeader ¶
func (*Context) BindWWWFormURLEncoded ¶
func (*Context) BodyReader ¶
func (r *Context) BodyReader() *h1.BodyReader
func (*Context) ChunkedBodyWriter ¶
func (r *Context) ChunkedBodyWriter() ChunkedBodyWriter
func (*Context) CloseBodyReader ¶
func (r *Context) CloseBodyReader()
func (*Context) ConnectionClose ¶
func (r *Context) ConnectionClose()
func (*Context) FastBodyUnsafe ¶
func (*Context) GetQueryParamString ¶
func (*Context) HijackConn ¶
func (*Context) Host ¶ added in v1.3.0
(*Context).Host returns the value of the Host header. Returned value is valid until the next request.
func (*Context) HostBytes ¶ added in v1.3.0
(*Context).HostBytes returns the value of the Host header. Returned value is valid until the next request.
func (*Context) QueryParams ¶
func (*Context) RemoteAddr ¶ added in v1.3.0
(*Context).RemoteAddr returns the remote address.
func (*Context) RequestHeaders ¶
func (r *Context) RequestHeaders() RequestHeaders
func (*Context) ResponseHeaders ¶
func (r *Context) ResponseHeaders() ResponseHeaders
func (*Context) ServerSentEventWriter ¶
func (r *Context) ServerSentEventWriter() ServerSentEventWriter
func (*Context) SetContentLength ¶
func (*Context) UpgradeWebSocket ¶
Upgrade the request to WebSocket protocol. param:
op: the opcode to use for the WebSocket connection. (ws.OpText|ws.OpBinary)
func (*Context) WriteFullBodyString ¶
func (*Context) WriteHeader ¶
func (*Context) WriteJSONIndent ¶
func (*Context) WriteJSONStream ¶ added in v1.2.0
func (*Context) XWWWFormURLEncoded ¶
func (r *Context) XWWWFormURLEncoded(maxSize int64) (*XWWWFormURLEncoded, error)
type RequestHeaders ¶
type RequestHeaders struct {
// contains filtered or unexported fields
}
func (RequestHeaders) Get ¶
func (r RequestHeaders) Get(name string) (string, bool)
(RequestHeaders).Get returns the value of the header with the given name.
Returned value is valid until the next request.
func (RequestHeaders) GetBytes ¶
func (r RequestHeaders) GetBytes(name []byte) ([]byte, bool)
(RequestHeaders).GetBytes returns the value of the header with the given name.
Returned value is valid until the next request.
func (RequestHeaders) List ¶
func (r RequestHeaders) List() []h1.Header
(RequestHeaders).List returns a slice of all the headers.
Returned value is valid until the next request.
type ResponseHeaders ¶
type ResponseHeaders struct {
// contains filtered or unexported fields
}
func (ResponseHeaders) Del ¶
func (r ResponseHeaders) Del(name string)
func (ResponseHeaders) Set ¶
func (r ResponseHeaders) Set(name, value string)
type Server ¶
type ServerSentEventWriter ¶
type ServerSentEventWriter struct {
// contains filtered or unexported fields
}
func (ServerSentEventWriter) Flush ¶
func (s ServerSentEventWriter) Flush() error
func (ServerSentEventWriter) Send ¶
func (s ServerSentEventWriter) Send(id, event, data string) error
func (ServerSentEventWriter) WriteHeartbeat ¶
func (s ServerSentEventWriter) WriteHeartbeat() error
type XWWWFormURLEncoded ¶
type XWWWFormURLEncoded struct {
// contains filtered or unexported fields
}
func (*XWWWFormURLEncoded) Close ¶
func (x *XWWWFormURLEncoded) Close()
func (*XWWWFormURLEncoded) GetString ¶
func (x *XWWWFormURLEncoded) GetString(key string) (string, bool)
func (*XWWWFormURLEncoded) GetStringUnsafe ¶
func (x *XWWWFormURLEncoded) GetStringUnsafe(key string) (string, bool)
func (*XWWWFormURLEncoded) Len ¶
func (x *XWWWFormURLEncoded) Len() int
Source Files ¶
Click to show internal directories.
Click to hide internal directories.