Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Close() error
- func (c *Client) Read() (int, []byte, error)
- func (c *Client) ReadCBOR(v interface{}) (err error)
- func (c *Client) ReadJSON(v interface{}) (err error)
- func (c *Client) ReadPACK(v interface{}) (err error)
- func (c *Client) ReadXML(v interface{}) (err error)
- func (c *Client) Rpc() (chan<- *RPCRequest, <-chan *RPCResponse, chan error)
- func (c *Client) Send(t int, data []byte) (err error)
- func (c *Client) SendCBOR(data interface{}) (err error)
- func (c *Client) SendJSON(data interface{}) (err error)
- func (c *Client) SendPACK(data interface{}) (err error)
- func (c *Client) SendText(data string) (err error)
- func (c *Client) SendXML(data interface{}) (err error)
- type Context
- func (c *Context) Bind(i interface{}) (err error)
- func (c *Context) Body() []byte
- func (c *Context) CBOR(code int, data interface{}) (err error)
- func (c *Context) Code(code int) (err error)
- func (c *Context) Context() context.Context
- func (c *Context) Data(code int, data interface{}, mime string) (err error)
- func (c *Context) Error(err error)
- func (c *Context) Fibre() *Fibre
- func (c *Context) File(path string) (err error)
- func (c *Context) Form(name string) (v string)
- func (c *Context) Get(key string) interface{}
- func (c *Context) HTML(code int, data interface{}) (err error)
- func (c *Context) Head() map[string]string
- func (c *Context) IP() net.IP
- func (c *Context) IsComplete() bool
- func (c *Context) IsOrigin() bool
- func (c *Context) IsSocket() bool
- func (c *Context) IsTLS() bool
- func (c *Context) JSON(code int, data interface{}) (err error)
- func (c *Context) Origin() (v string)
- func (c *Context) PACK(code int, data interface{}) (err error)
- func (c *Context) Param(name string) (v string)
- func (c *Context) Path() string
- func (c *Context) Query(name string) (v string)
- func (c *Context) Redirect(code int, url string) (err error)
- func (c *Context) Request() *Request
- func (c *Context) Response() *Response
- func (c *Context) Send(code int, data interface{}) (err error)
- func (c *Context) Set(key string, val interface{})
- func (c *Context) Socket() *Socket
- func (c *Context) Text(code int, data interface{}) (err error)
- func (c *Context) Type() string
- func (c *Context) Uniq() string
- func (c *Context) Upgrade(protocols ...string) (err error)
- func (c *Context) WithContext(ctx context.Context) *Context
- func (c *Context) XML(code int, data interface{}) (err error)
- type Fibre
- func (f *Fibre) Any(p string, h HandlerFunc)
- func (f *Fibre) Connect(p string, h HandlerFunc)
- func (f *Fibre) Delete(p string, h HandlerFunc)
- func (f *Fibre) Dir(p, dir string)
- func (f *Fibre) File(p, file string)
- func (f *Fibre) Get(p string, h HandlerFunc)
- func (f *Fibre) Head(p string, h HandlerFunc)
- func (f *Fibre) Logger() *Logger
- func (f *Fibre) Name() string
- func (f *Fibre) Options(p string, h HandlerFunc)
- func (f *Fibre) Patch(p string, h HandlerFunc)
- func (f *Fibre) Post(p string, h HandlerFunc)
- func (f *Fibre) Pprof()
- func (f *Fibre) Put(p string, h HandlerFunc)
- func (f *Fibre) Router() *Router
- func (f *Fibre) Rpc(p string, i interface{})
- func (f *Fibre) Run(a string, files ...string)
- func (f *Fibre) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (f *Fibre) SetHTTPErrorHandler(h HTTPErrorHandler)
- func (f *Fibre) SetIdleTimeout(wait string)
- func (f *Fibre) SetLogFormat(l string)
- func (f *Fibre) SetLogLevel(l string)
- func (f *Fibre) SetName(name string)
- func (f *Fibre) SetReadTimeout(wait string)
- func (f *Fibre) SetWriteTimeout(wait string)
- func (f *Fibre) Trace(p string, h HandlerFunc)
- func (f *Fibre) Use(m MiddlewareFunc) MiddlewareFunc
- type HTTPError
- func (e *HTTPError) Code() int
- func (e *HTTPError) Error() string
- func (e *HTTPError) Fields() map[string]interface{}
- func (e *HTTPError) WithField(k string, v interface{}) *HTTPError
- func (e *HTTPError) WithFields(f map[string]interface{}) *HTTPError
- func (e *HTTPError) WithMessage(m string) *HTTPError
- type HTTPErrorHandler
- type HandlerFunc
- type Logger
- type Middleware
- type MiddlewareFunc
- func (m MiddlewareFunc) AgentBegsWith(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) AgentEndsWith(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) AgentIs(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) AgentIsNot(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) AgentMatches(tests ...regexp.Regexp) MiddlewareFunc
- func (m MiddlewareFunc) HostBegsWith(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) HostEndsWith(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) HostIs(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) HostIsNot(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) HostMatches(tests ...regexp.Regexp) MiddlewareFunc
- func (m MiddlewareFunc) MethodBegsWith(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) MethodEndsWith(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) MethodIs(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) MethodIsNot(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) MethodMatches(tests ...regexp.Regexp) MiddlewareFunc
- func (m MiddlewareFunc) PathBegsWith(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) PathEndsWith(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) PathIs(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) PathIsNot(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) PathMatches(tests ...regexp.Regexp) MiddlewareFunc
- func (m MiddlewareFunc) SchemeBegsWith(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) SchemeEndsWith(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) SchemeIs(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) SchemeIsNot(tests ...string) MiddlewareFunc
- func (m MiddlewareFunc) SchemeMatches(tests ...regexp.Regexp) MiddlewareFunc
- type RPCError
- type RPCNotification
- type RPCNull
- type RPCRequest
- type RPCResponse
- type Request
- type Response
- func (r *Response) CloseNotify() <-chan bool
- func (r *Response) Done() bool
- func (r *Response) Flush()
- func (r *Response) Header() http.Header
- func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (r *Response) SetWriter(w http.ResponseWriter)
- func (r *Response) Size() int64
- func (r *Response) Status() int
- func (r *Response) Write(b []byte) (n int, err error)
- func (r *Response) WriteHeader(code int)
- func (r *Response) Writer() http.ResponseWriter
- type Route
- type Router
- type Socket
- func (s *Socket) Close(code int) error
- func (s *Socket) Notify(val *RPCNotification)
- func (s *Socket) Read() (int, []byte, error)
- func (s *Socket) ReadCBOR(v interface{}) (err error)
- func (s *Socket) ReadJSON(v interface{}) (err error)
- func (s *Socket) ReadPACK(v interface{}) (err error)
- func (s *Socket) ReadXML(v interface{}) (err error)
- func (s *Socket) Send(t int, data []byte) (err error)
- func (s *Socket) SendCBOR(data interface{}) (err error)
- func (s *Socket) SendJSON(data interface{}) (err error)
- func (s *Socket) SendPACK(data interface{}) (err error)
- func (s *Socket) SendText(data string) (err error)
- func (s *Socket) SendXML(data interface{}) (err error)
- type URL
Constants ¶
const ( // HEAD ... HEAD = "HEAD" // GET ... GET = "GET" // PUT ... PUT = "PUT" // POST ... POST = "POST" // PATCH ... PATCH = "PATCH" // TRACE ... TRACE = "TRACE" // DELETE ... DELETE = "DELETE" // OPTIONS ... OPTIONS = "OPTIONS" // CONNECT ... CONNECT = "CONNECT" )
const ( HeaderAccept = "Accept" HeaderAcceptEncoding = "Accept-Encoding" HeaderAllow = "Allow" HeaderAuthenticate = "WWW-Authenticate" HeaderAuthorization = "Authorization" HeaderContentDisposition = "Content-Disposition" HeaderContentEncoding = "Content-Encoding" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderCookie = "Cookie" HeaderIfModifiedSince = "If-Modified-Since" HeaderLastModified = "Last-Modified" HeaderLocation = "Location" HeaderOrigin = "Origin" HeaderServer = "Server" HeaderSetCookie = "Set-Cookie" HeaderUpgrade = "Upgrade" HeaderVary = "Vary" HeaderXForwardedFor = "X-Forwarded-For" HeaderXForwardedProto = "X-Forwarded-Proto" HeaderXForwardedProtocol = "X-Forwarded-Protocol" HeaderXForwardedSsl = "X-Forwarded-Ssl" HeaderXHTTPMethodOverride = "X-HTTP-Method-Override" HeaderXPoweredBy = "X-Powered-By" HeaderXRealIP = "X-Real-IP" HeaderXRequestID = "X-Request-ID" HeaderXUrlScheme = "X-Url-Scheme" // Access control HeaderAccessControlRequestMethod = "Access-Control-Request-Method" HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers" HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin" HeaderAccessControlAllowMethods = "Access-Control-Allow-Methods" HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers" HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials" HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers" HeaderAccessControlMaxAge = "Access-Control-Max-Age" // Security HeaderContentSecurityPolicy = "Content-Security-Policy" HeaderPublicKeyPins = "Public-Key-Pins" HeaderStrictTransportSecurity = "Strict-Transport-Security" HeaderXContentTypeOptions = "X-Content-Type-Options" HeaderXCSRFToken = "X-CSRF-Token" HeaderXFrameOptions = "X-Frame-Options" HeaderXXSSProtection = "X-XSS-Protection" )
Variables ¶
var MiddlewareSkip = func(h HandlerFunc) HandlerFunc { return func(c *Context) error { return h(c) } }
Functions ¶
This section is empty.
Types ¶
type Client ¶
Socket wraps an websocket.Conn
func (*Client) Rpc ¶
func (c *Client) Rpc() (chan<- *RPCRequest, <-chan *RPCResponse, chan error)
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context represents context for the current request.
func NewContext ¶
NewContext creates a Context object.
func (*Context) Error ¶
Error invokes the registered HTTP error handler. Generally used by middleware.
func (*Context) IsComplete ¶
IsComplete returns true if the response has been closed.
type Fibre ¶
type Fibre struct {
// contains filtered or unexported fields
}
Fibre represents an HTTP server
func (*Fibre) Any ¶
func (f *Fibre) Any(p string, h HandlerFunc)
Any adds a route > handler to the router for all HTTP methods.
func (*Fibre) Connect ¶
func (f *Fibre) Connect(p string, h HandlerFunc)
Connect adds a CONNECT route > handler to the router.
func (*Fibre) Delete ¶
func (f *Fibre) Delete(p string, h HandlerFunc)
Delete adds a DELETE route > handler to the router.
func (*Fibre) Get ¶
func (f *Fibre) Get(p string, h HandlerFunc)
Get adds a GET route > handler to the router.
func (*Fibre) Head ¶
func (f *Fibre) Head(p string, h HandlerFunc)
Head adds a HEAD route > handler to the router.
func (*Fibre) Options ¶
func (f *Fibre) Options(p string, h HandlerFunc)
Options adds an OPTIONS route > handler to the router.
func (*Fibre) Patch ¶
func (f *Fibre) Patch(p string, h HandlerFunc)
Patch adds a PATCH route > handler to the router.
func (*Fibre) Post ¶
func (f *Fibre) Post(p string, h HandlerFunc)
Post adds a POST route > handler to the router.
func (*Fibre) Put ¶
func (f *Fibre) Put(p string, h HandlerFunc)
Put adds a PUT route > handler to the router.
func (*Fibre) ServeHTTP ¶
func (f *Fibre) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements `http.Handler` interface, which serves HTTP requests.
func (*Fibre) SetHTTPErrorHandler ¶
func (f *Fibre) SetHTTPErrorHandler(h HTTPErrorHandler)
SetHTTPErrorHandler registers a custom Echo.HTTPErrorHandler.
func (*Fibre) SetIdleTimeout ¶
SetIdleTimeout sets the max idle time for a keepalive connection.
func (*Fibre) SetLogFormat ¶
SetLogFormat sets the logger log format.
func (*Fibre) SetLogLevel ¶
SetLogLevel sets the logger log level.
func (*Fibre) SetReadTimeout ¶
SetReadTimeout sets the max duration for reading requests.
func (*Fibre) SetWriteTimeout ¶
SetWriteTimeout sets the max duration for writing responses.
func (*Fibre) Trace ¶
func (f *Fibre) Trace(p string, h HandlerFunc)
Trace adds a TRACE route > handler to the router.
func (*Fibre) Use ¶
func (f *Fibre) Use(m MiddlewareFunc) MiddlewareFunc
Use adds a middleware function
type HTTPError ¶
type HTTPError struct {
// contains filtered or unexported fields
}
HTTPError represents an error that occurred while handling a request.
func NewHTTPError ¶
NewHTTPError creates a new instance of HTTPError.
func (*HTTPError) WithFields ¶
func (*HTTPError) WithMessage ¶
type HTTPErrorHandler ¶
HTTPErrorHandler is a centralized HTTP error handler.
type MiddlewareFunc ¶
type MiddlewareFunc func(HandlerFunc) HandlerFunc
MiddlewareFunc represents a request middleware
func (MiddlewareFunc) AgentBegsWith ¶
func (m MiddlewareFunc) AgentBegsWith(tests ...string) MiddlewareFunc
AgentBegsWith checks if the request agent begins with a value, and if it does then the middleware will be invoked.
func (MiddlewareFunc) AgentEndsWith ¶
func (m MiddlewareFunc) AgentEndsWith(tests ...string) MiddlewareFunc
AgentEndsWith checks if the request agent ends with a value, and if it does then the middleware will be invoked.
func (MiddlewareFunc) AgentIs ¶
func (m MiddlewareFunc) AgentIs(tests ...string) MiddlewareFunc
AgentIs checks if the request agent is exactly equal to a value, and if it is then the middleware will be invoked.
func (MiddlewareFunc) AgentIsNot ¶
func (m MiddlewareFunc) AgentIsNot(tests ...string) MiddlewareFunc
AgentIsNot checks if the request agent is not exactly equal to a value, and if it isn't then the middleware will be invoked.
func (MiddlewareFunc) AgentMatches ¶
func (m MiddlewareFunc) AgentMatches(tests ...regexp.Regexp) MiddlewareFunc
AgentMatches checks if the request agent matches a regular expression, and if it does then the middleware will be invoked.
func (MiddlewareFunc) HostBegsWith ¶
func (m MiddlewareFunc) HostBegsWith(tests ...string) MiddlewareFunc
HostBegsWith checks if the request host begins with a value, and if it does then the middleware will be invoked.
func (MiddlewareFunc) HostEndsWith ¶
func (m MiddlewareFunc) HostEndsWith(tests ...string) MiddlewareFunc
HostEndsWith checks if the request host ends with a value, and if it does then the middleware will be invoked.
func (MiddlewareFunc) HostIs ¶
func (m MiddlewareFunc) HostIs(tests ...string) MiddlewareFunc
HostIs checks if the request host is exactly equal to a value, and if it is then the middleware will be invoked.
func (MiddlewareFunc) HostIsNot ¶
func (m MiddlewareFunc) HostIsNot(tests ...string) MiddlewareFunc
HostIsNot checks if the request host is not exactly equal to a value, and if it isn't then the middleware will be invoked.
func (MiddlewareFunc) HostMatches ¶
func (m MiddlewareFunc) HostMatches(tests ...regexp.Regexp) MiddlewareFunc
HostMatches checks if the request host matches a regular expression, and if it does then the middleware will be invoked.
func (MiddlewareFunc) MethodBegsWith ¶
func (m MiddlewareFunc) MethodBegsWith(tests ...string) MiddlewareFunc
MethodBegsWith checks if the request method begins with a value, and if it does then the middleware will be invoked.
func (MiddlewareFunc) MethodEndsWith ¶
func (m MiddlewareFunc) MethodEndsWith(tests ...string) MiddlewareFunc
MethodEndsWith checks if the request method ends with a value, and if it does then the middleware will be invoked.
func (MiddlewareFunc) MethodIs ¶
func (m MiddlewareFunc) MethodIs(tests ...string) MiddlewareFunc
MethodIs checks if the request method is exactly equal to a value, and if it is then the middleware will be invoked.
func (MiddlewareFunc) MethodIsNot ¶
func (m MiddlewareFunc) MethodIsNot(tests ...string) MiddlewareFunc
MethodIsNot checks if the request method is not exactly equal to a value, and if it isn't then the middleware will be invoked.
func (MiddlewareFunc) MethodMatches ¶
func (m MiddlewareFunc) MethodMatches(tests ...regexp.Regexp) MiddlewareFunc
MethodMatches checks if the request method matches a regular expression, and if it does then the middleware will be invoked.
func (MiddlewareFunc) PathBegsWith ¶
func (m MiddlewareFunc) PathBegsWith(tests ...string) MiddlewareFunc
PathBegsWith checks if the request oath begins with a value, and if it does then the middleware will be invoked.
func (MiddlewareFunc) PathEndsWith ¶
func (m MiddlewareFunc) PathEndsWith(tests ...string) MiddlewareFunc
PathEndsWith checks if the request oath ends with a value, and if it does then the middleware will be invoked.
func (MiddlewareFunc) PathIs ¶
func (m MiddlewareFunc) PathIs(tests ...string) MiddlewareFunc
PathIs checks if the request oath is exactly equal to a value, and if it is then the middleware will be invoked.
func (MiddlewareFunc) PathIsNot ¶
func (m MiddlewareFunc) PathIsNot(tests ...string) MiddlewareFunc
PathIsNot checks if the request oath is not exactly equal to a value, and if it isn't then the middleware will be invoked.
func (MiddlewareFunc) PathMatches ¶
func (m MiddlewareFunc) PathMatches(tests ...regexp.Regexp) MiddlewareFunc
PathMatches checks if the request oath matches a regular expression, and if it does then the middleware will be invoked.
func (MiddlewareFunc) SchemeBegsWith ¶
func (m MiddlewareFunc) SchemeBegsWith(tests ...string) MiddlewareFunc
SchemeBegsWith checks if the request scheme begins with a value, and if it does then the middleware will be invoked.
func (MiddlewareFunc) SchemeEndsWith ¶
func (m MiddlewareFunc) SchemeEndsWith(tests ...string) MiddlewareFunc
SchemeEndsWith checks if the request scheme ends with a value, and if it does then the middleware will be invoked.
func (MiddlewareFunc) SchemeIs ¶
func (m MiddlewareFunc) SchemeIs(tests ...string) MiddlewareFunc
SchemeIs checks if the request scheme is exactly equal to a value, and if it is then the middleware will be invoked.
func (MiddlewareFunc) SchemeIsNot ¶
func (m MiddlewareFunc) SchemeIsNot(tests ...string) MiddlewareFunc
SchemeIsNot checks if the request scheme is not exactly equal to a value, and if it isn't then the middleware will be invoked.
func (MiddlewareFunc) SchemeMatches ¶
func (m MiddlewareFunc) SchemeMatches(tests ...regexp.Regexp) MiddlewareFunc
SchemeMatches checks if the request scheme matches a regular expression, and if it does then the middleware will be invoked.
type RPCError ¶
type RPCError struct { Code int `json:"code" msgpack:"code"` Message string `json:"message,omitempty" msgpack:"message,omitempty"` }
RPCError represents a jsonrpc error
type RPCNotification ¶
type RPCNotification struct { ID interface{} `json:"id" msgpack:"id"` Method string `json:"method,omitempty" msgpack:"method,omitempty"` Params []interface{} `json:"params,omitempty" msgpack:"params,omitempty"` }
RPCNotification represents an outgoing jsonrpc notification
type RPCRequest ¶
type RPCRequest struct { ID interface{} `json:"id" msgpack:"id"` Async bool `json:"async,omitempty" msgpack:"async,omitempty"` Method string `json:"method,omitempty" msgpack:"method,omitempty"` Params []interface{} `json:"params,omitempty" msgpack:"params,omitempty"` }
RPCRequest represents an incoming jsonrpc request
type RPCResponse ¶
type RPCResponse struct { ID interface{} `json:"id" msgpack:"id"` Error *RPCError `json:"error,omitempty" msgpack:"error,omitempty"` Result interface{} `json:"result,omitempty" msgpack:"result,omitempty"` }
RPCResponse represents an outgoing jsonrpc response
type Request ¶
Request wraps an http.Request
func NewRequest ¶
NewRequest creates a new instance of Response.
type Response ¶
type Response struct { http.ResponseWriter // contains filtered or unexported fields }
Response wraps an http.Response
func NewResponse ¶
func NewResponse(i http.ResponseWriter, f *Fibre) *Response
NewResponse creates a new instance of Response.
func (*Response) CloseNotify ¶
CloseNotify enables detecting when the underlying connection has gone away.
func (*Response) SetWriter ¶
func (r *Response) SetWriter(w http.ResponseWriter)
SetWriter sets the http.ResponseWriter instance for this Response.
func (*Response) WriteHeader ¶
WriteHeader sends an HTTP response header with status code. If WriteHeader is not called explicitly, the first call to Write will trigger an implicit WriteHeader(http.StatusOK). Thus explicit calls to WriteHeader are mainly used to send error codes.
func (*Response) Writer ¶
func (r *Response) Writer() http.ResponseWriter
Writer returns the http.ResponseWriter instance for this Response.
type Route ¶
type Route struct { Rank int Path string Method string Handler HandlerFunc }
Route stores a handler for matching paths against requests.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router stores routes used in request matching and handler dispatching.
func (*Router) Add ¶
func (r *Router) Add(meth, path string, hand HandlerFunc)
Add registers a new route with a matcher for the URL path.
type Socket ¶
Socket wraps an websocket.Conn
func (*Socket) Notify ¶
func (s *Socket) Notify(val *RPCNotification)