package echo
import "github.com/labstack/echo"
Index ¶
- Constants
- Variables
- type Binder
- type Context
- type Echo
- func New() (e *Echo)
- func (e *Echo) Any(path string, handler Handler, middleware ...Middleware)
- func (e *Echo) Connect(path string, h Handler, m ...Middleware)
- func (e *Echo) Debug() bool
- func (e *Echo) DefaultHTTPErrorHandler(err error, c Context)
- func (e *Echo) Delete(path string, h Handler, m ...Middleware)
- func (e *Echo) Get(path string, h Handler, m ...Middleware)
- func (e *Echo) Group(prefix string, m ...Middleware) (g *Group)
- func (e *Echo) Head(path string, h Handler, m ...Middleware)
- func (e *Echo) Logger() *log.Logger
- func (e *Echo) Match(methods []string, path string, handler Handler, middleware ...Middleware)
- func (e *Echo) Options(path string, h Handler, m ...Middleware)
- func (e *Echo) Patch(path string, h Handler, m ...Middleware)
- func (e *Echo) Post(path string, h Handler, m ...Middleware)
- func (e *Echo) Put(path string, h Handler, m ...Middleware)
- func (e *Echo) Router() *Router
- func (e *Echo) Routes() []Route
- func (e *Echo) Run(eng engine.Engine)
- func (e *Echo) ServeHTTP(req engine.Request, res engine.Response)
- func (e *Echo) SetBinder(b Binder)
- func (e *Echo) SetDebug(on bool)
- func (e *Echo) SetHTTPErrorHandler(h HTTPErrorHandler)
- func (e *Echo) SetLogLevel(l log.Level)
- func (e *Echo) SetLogOutput(w io.Writer)
- func (e *Echo) SetLogPrefix(prefix string)
- func (e *Echo) SetRenderer(r Renderer)
- func (e *Echo) Trace(path string, h Handler, m ...Middleware)
- func (e *Echo) URI(handler Handler, params ...interface{}) string
- func (e *Echo) URL(h Handler, params ...interface{}) string
- func (e *Echo) Use(middleware ...Middleware)
- type Group
- func (g *Group) Any(path string, handler Handler, middleware ...Middleware)
- func (g *Group) Connect(path string, h Handler, m ...Middleware)
- func (g *Group) Delete(path string, h Handler, m ...Middleware)
- func (g *Group) Get(path string, h Handler, m ...Middleware)
- func (g *Group) Group(prefix string, m ...Middleware) *Group
- func (g *Group) Head(path string, h Handler, m ...Middleware)
- func (g *Group) Match(methods []string, path string, handler Handler, middleware ...Middleware)
- func (g *Group) Options(path string, h Handler, m ...Middleware)
- func (g *Group) Patch(path string, h Handler, m ...Middleware)
- func (g *Group) Post(path string, h Handler, m ...Middleware)
- func (g *Group) Put(path string, h Handler, m ...Middleware)
- func (g *Group) Trace(path string, h Handler, m ...Middleware)
- func (g *Group) Use(m ...Middleware)
- type HTTPError
- func NewHTTPError(code int, msg ...string) *HTTPError
- func (e *HTTPError) Code() int
- func (e *HTTPError) Error() string
- func (e *HTTPError) SetCode(code int)
- type HTTPErrorHandler
- type Handler
- type HandlerFunc
- type Middleware
- type MiddlewareFunc
- type Renderer
- type Route
- type Router
- func NewRouter(e *Echo) *Router
- func (r *Router) Add(method, path string, h Handler, e *Echo)
- func (r *Router) Find(method, path string, context Context)
- func (r *Router) Handle(h Handler) Handler
- func (r *Router) Priority() int
- type Validator
Constants ¶
const ( // CONNECT HTTP method CONNECT = "CONNECT" // DELETE HTTP method DELETE = "DELETE" // GET HTTP method GET = "GET" // HEAD HTTP method HEAD = "HEAD" // OPTIONS HTTP method OPTIONS = "OPTIONS" // PATCH HTTP method PATCH = "PATCH" // POST HTTP method POST = "POST" // PUT HTTP method PUT = "PUT" // TRACE HTTP method TRACE = "TRACE" ApplicationJSON = "application/json" ApplicationJSONCharsetUTF8 = ApplicationJSON + "; " + CharsetUTF8 ApplicationJavaScript = "application/javascript" ApplicationJavaScriptCharsetUTF8 = ApplicationJavaScript + "; " + CharsetUTF8 ApplicationXML = "application/xml" ApplicationXMLCharsetUTF8 = ApplicationXML + "; " + CharsetUTF8 ApplicationForm = "application/x-www-form-urlencoded" ApplicationProtobuf = "application/protobuf" ApplicationMsgpack = "application/msgpack" TextHTML = "text/html" TextHTMLCharsetUTF8 = TextHTML + "; " + CharsetUTF8 TextPlain = "text/plain" TextPlainCharsetUTF8 = TextPlain + "; " + CharsetUTF8 MultipartForm = "multipart/form-data" OctetStream = "application/octet-stream" CharsetUTF8 = "charset=utf-8" AcceptEncoding = "Accept-Encoding" Authorization = "Authorization" ContentDisposition = "Content-Disposition" ContentEncoding = "Content-Encoding" ContentLength = "Content-Length" ContentType = "Content-Type" Location = "Location" Upgrade = "Upgrade" Vary = "Vary" WWWAuthenticate = "WWW-Authenticate" XForwardedFor = "X-Forwarded-For" XRealIP = "X-Real-IP" )
Variables ¶
var ( ErrUnsupportedMediaType = NewHTTPError(http.StatusUnsupportedMediaType) ErrNotFound = NewHTTPError(http.StatusNotFound) ErrRendererNotRegistered = errors.New("renderer not registered") ErrInvalidRedirectCode = errors.New("invalid redirect status code") )
Types ¶
type Binder ¶
Binder is the interface that wraps the Bind method.
type Context ¶
type Context interface { netContext.Context Request() engine.Request Response() engine.Response Path() string P(int) string Param(string) string ParamNames() []string Query(string) string Form(string) string Set(string, interface{}) Get(string) interface{} Bind(interface{}) error Render(int, string, interface{}) error HTML(int, string) error String(int, string) error JSON(int, interface{}) error JSONBlob(int, []byte) error JSONP(int, string, interface{}) error XML(int, interface{}) error XMLBlob(int, []byte) error Attachment(string) error NoContent(int) error Redirect(int, string) error Error(err error) Handle(Context) error Logger() *log.Logger Echo() *Echo Object() *context }
Context represents context for the current request. It holds request and response objects, path parameters, data and registered handler.
func NewContext ¶
NewContext creates a Context object.
type Echo ¶
type Echo struct {
// contains filtered or unexported fields
}
func New ¶
func New() (e *Echo)
New creates an instance of Echo.
func (*Echo) Any ¶
func (e *Echo) Any(path string, handler Handler, middleware ...Middleware)
Any adds a route > handler to the router for all HTTP methods.
func (*Echo) Connect ¶
func (e *Echo) Connect(path string, h Handler, m ...Middleware)
Connect adds a CONNECT route > handler to the router.
func (*Echo) Debug ¶
Debug returns debug mode (enabled or disabled).
func (*Echo) DefaultHTTPErrorHandler ¶
DefaultHTTPErrorHandler invokes the default HTTP error handler.
func (*Echo) Delete ¶
func (e *Echo) Delete(path string, h Handler, m ...Middleware)
Delete adds a DELETE route > handler to the router.
func (*Echo) Get ¶
func (e *Echo) Get(path string, h Handler, m ...Middleware)
Get adds a GET route > handler to the router.
func (*Echo) Group ¶
func (e *Echo) Group(prefix string, m ...Middleware) (g *Group)
Group creates a new sub-router with prefix.
func (*Echo) Head ¶
func (e *Echo) Head(path string, h Handler, m ...Middleware)
Head adds a HEAD route > handler to the router.
func (*Echo) Logger ¶
Logger returns the logger instance.
func (*Echo) Match ¶
func (e *Echo) Match(methods []string, path string, handler Handler, middleware ...Middleware)
Match adds a route > handler to the router for multiple HTTP methods provided.
func (*Echo) Options ¶
func (e *Echo) Options(path string, h Handler, m ...Middleware)
Options adds an OPTIONS route > handler to the router.
func (*Echo) Patch ¶
func (e *Echo) Patch(path string, h Handler, m ...Middleware)
Patch adds a PATCH route > handler to the router.
func (*Echo) Post ¶
func (e *Echo) Post(path string, h Handler, m ...Middleware)
Post adds a POST route > handler to the router.
func (*Echo) Put ¶
func (e *Echo) Put(path string, h Handler, m ...Middleware)
Put adds a PUT route > handler to the router.
func (*Echo) Router ¶
Router returns router.
func (*Echo) Routes ¶
Routes returns the registered routes.
func (*Echo) Run ¶
Run starts the HTTP engine.
func (*Echo) ServeHTTP ¶
func (*Echo) SetBinder ¶
SetBinder registers a custom binder. It's invoked by Context.Bind().
func (*Echo) SetDebug ¶
SetDebug enable/disable debug mode.
func (*Echo) SetHTTPErrorHandler ¶
func (e *Echo) SetHTTPErrorHandler(h HTTPErrorHandler)
SetHTTPErrorHandler registers a custom Echo.HTTPErrorHandler.
func (*Echo) SetLogLevel ¶
SetLogLevel sets the log level for the logger. Default value is `log.FATAL`.
func (*Echo) SetLogOutput ¶
SetLogOutput sets the output destination for the logger. Default value is `os.Std*`
func (*Echo) SetLogPrefix ¶
SetLogPrefix sets the prefix for the logger. Default value is `echo`.
func (*Echo) SetRenderer ¶
SetRenderer registers an HTML template renderer. It's invoked by Context.Render().
func (*Echo) Trace ¶
func (e *Echo) Trace(path string, h Handler, m ...Middleware)
Trace adds a TRACE route > handler to the router.
func (*Echo) URI ¶
URI generates a URI from handler.
func (*Echo) URL ¶
URL is an alias for `URI` function.
func (*Echo) Use ¶
func (e *Echo) Use(middleware ...Middleware)
Use adds handler to the middleware chain.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) Any ¶
func (g *Group) Any(path string, handler Handler, middleware ...Middleware)
func (*Group) Connect ¶
func (g *Group) Connect(path string, h Handler, m ...Middleware)
func (*Group) Delete ¶
func (g *Group) Delete(path string, h Handler, m ...Middleware)
func (*Group) Get ¶
func (g *Group) Get(path string, h Handler, m ...Middleware)
func (*Group) Group ¶
func (g *Group) Group(prefix string, m ...Middleware) *Group
func (*Group) Head ¶
func (g *Group) Head(path string, h Handler, m ...Middleware)
func (*Group) Match ¶
func (g *Group) Match(methods []string, path string, handler Handler, middleware ...Middleware)
func (*Group) Options ¶
func (g *Group) Options(path string, h Handler, m ...Middleware)
func (*Group) Patch ¶
func (g *Group) Patch(path string, h Handler, m ...Middleware)
func (*Group) Post ¶
func (g *Group) Post(path string, h Handler, m ...Middleware)
func (*Group) Put ¶
func (g *Group) Put(path string, h Handler, m ...Middleware)
func (*Group) Trace ¶
func (g *Group) Trace(path string, h Handler, m ...Middleware)
func (*Group) Use ¶
func (g *Group) Use(m ...Middleware)
type HTTPError ¶
type HTTPError struct {
// contains filtered or unexported fields
}
func NewHTTPError ¶
func (*HTTPError) Code ¶
Code returns code.
func (*HTTPError) Error ¶
Error returns message.
func (*HTTPError) SetCode ¶
SetCode sets code.
type HTTPErrorHandler ¶
HTTPErrorHandler is a centralized HTTP error handler.
type Handler ¶
type HandlerFunc ¶
func (HandlerFunc) Handle ¶
func (h HandlerFunc) Handle(c Context) error
type Middleware ¶
type MiddlewareFunc ¶
func WrapMiddleware ¶
func WrapMiddleware(h Handler) MiddlewareFunc
WrapMiddleware wrap `echo.Handler` into `echo.MiddlewareFunc`.
func (MiddlewareFunc) Handle ¶
func (m MiddlewareFunc) Handle(h Handler) Handler
type Renderer ¶
Renderer is the interface that wraps the Render method.
type Route ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func NewRouter ¶
func (*Router) Add ¶
func (*Router) Find ¶
func (*Router) Handle ¶
func (*Router) Priority ¶
type Validator ¶
type Validator interface { Validate() error }
Validator is the interface that wraps the Validate method.
Source Files ¶
context.go echo.go group.go router.go
Directories ¶
Path | Synopsis |
---|---|
engine | |
engine/fasthttp | |
engine/standard | |
middleware | |
test |
- Version
- v2.0.0-beta.1+incompatible
- Published
- Mar 11, 2016
- Platform
- windows/amd64
- Imports
- 19 packages
- Last checked
- 5 seconds ago –
Tools for package owners.