nio

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2019 License: MIT Imports: 20 Imported by: 2

README

Build Status codecov GoDoc Go Report Card

Features

  • Zero external runtime dependencies
  • Smart HTTP Routing
  • Data binding for JSON, XML and form payload
  • Middlewares on global, group or single route level
  • Full control of http server

Builtin middlewares

  • Basic Auth
  • Body Dump
  • Body Limit
  • Compress (GZip)
  • CORS
  • CSRF
  • Key Auth
  • Method Override
  • Recover
  • Request ID
  • Rewrite
  • Secure
  • Slash
  • Static

Getting Started

Prerequisites

You need to have at least go 1.11 installed on you local machine.

Installing

Install nio package with go get

go get -u github.com/go-nio/nio

Start your first awesome server. Create main.go file and add:

package main

import (
    "net/http"
    "log"
    "github.com/go-nio/nio"
)

func main() {
	// Nio instance
	n := nio.New()

	// Routes
	n.GET("/", hello)

	// Start server
	log.Fatal(http.ListenAndServe(":1323", n))
}

// Handler
func hello(c nio.Context) error {
	return c.String(http.StatusOK, "Hello, World!")
}

And finally run it

go run main.go

More examples

See examples

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Andzej Maciusovic - Initial work - anjmao

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • This project is largely ispired by echo. Parts of the code are adopted from echo. See NOTICE.

Documentation

Overview

Package nio implements modern and productive Go HTTP framework.

Example:

package main

import (
  "net/http"

  "github.com/go-nio/nio"
  "github.com/go-nio/nio/mw"
)

// Handler
func hello(c nio.Context) error {
  return c.String(http.StatusOK, "Hello, World!")
}

func main() {
  // Nio instance
  n := nio.New()

  // Middleware
  n.Use(mw.Logger())
  n.Use(mw.Recover())

  // Routes
  n.GET("/", hello)

  // Start server
  n.Logger().Fatal(http.ListenAndServe(":1323", n))
}

Learn more at https://github.com/go-nio/nio

Index

Constants

View Source
const (
	MIMEApplicationJSON                  = "application/json"
	MIMEApplicationJSONCharsetUTF8       = MIMEApplicationJSON + "; " + charsetUTF8
	MIMEApplicationJavaScript            = "application/javascript"
	MIMEApplicationJavaScriptCharsetUTF8 = MIMEApplicationJavaScript + "; " + charsetUTF8
	MIMEApplicationXML                   = "application/xml"
	MIMEApplicationXMLCharsetUTF8        = MIMEApplicationXML + "; " + charsetUTF8
	MIMETextXML                          = "text/xml"
	MIMETextXMLCharsetUTF8               = MIMETextXML + "; " + charsetUTF8
	MIMEApplicationForm                  = "application/x-www-form-urlencoded"
	MIMEApplicationProtobuf              = "application/protobuf"
	MIMEApplicationMsgpack               = "application/msgpack"
	MIMETextHTML                         = "text/html"
	MIMETextHTMLCharsetUTF8              = MIMETextHTML + "; " + charsetUTF8
	MIMETextPlain                        = "text/plain"
	MIMETextPlainCharsetUTF8             = MIMETextPlain + "; " + charsetUTF8
	MIMEMultipartForm                    = "multipart/form-data"
	MIMEOctetStream                      = "application/octet-stream"
)

MIME types

View Source
const (
	HeaderAccept              = "Accept"
	HeaderAcceptEncoding      = "Accept-Encoding"
	HeaderAllow               = "Allow"
	HeaderAuthorization       = "Authorization"
	HeaderContentDisposition  = "Content-Disposition"
	HeaderContentEncoding     = "Content-Encoding"
	HeaderContentLength       = "Content-Length"
	HeaderContentType         = "Content-Type"
	HeaderCookie              = "Cookie"
	HeaderSetCookie           = "Set-Cookie"
	HeaderIfModifiedSince     = "If-Modified-Since"
	HeaderLastModified        = "Last-Modified"
	HeaderLocation            = "Location"
	HeaderUpgrade             = "Upgrade"
	HeaderVary                = "Vary"
	HeaderWWWAuthenticate     = "WWW-Authenticate"
	HeaderXForwardedFor       = "X-Forwarded-For"
	HeaderXForwardedProto     = "X-Forwarded-Proto"
	HeaderXForwardedProtocol  = "X-Forwarded-Protocol"
	HeaderXForwardedSsl       = "X-Forwarded-Ssl"
	HeaderXUrlScheme          = "X-Url-Scheme"
	HeaderXHTTPMethodOverride = "X-HTTP-Method-Override"
	HeaderXRealIP             = "X-Real-IP"
	HeaderXRequestID          = "X-Request-ID"
	HeaderXRequestedWith      = "X-Requested-With"
	HeaderServer              = "Server"
	HeaderOrigin              = "Origin"

	// 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
	HeaderStrictTransportSecurity = "Strict-Transport-Security"
	HeaderXContentTypeOptions     = "X-Content-Type-Options"
	HeaderXXSSProtection          = "X-XSS-Protection"
	HeaderXFrameOptions           = "X-Frame-Options"
	HeaderContentSecurityPolicy   = "Content-Security-Policy"
	HeaderXCSRFToken              = "X-CSRF-Token"
)

Headers

View Source
const (

	// PROPFIND HTTP Header
	PROPFIND = "PROPFIND"
)
View Source
const Version = "1.0.2"

Version is nio version

Variables

View Source
var (
	ErrUnsupportedMediaType        = NewHTTPError(http.StatusUnsupportedMediaType)
	ErrNotFound                    = NewHTTPError(http.StatusNotFound)
	ErrUnauthorized                = NewHTTPError(http.StatusUnauthorized)
	ErrForbidden                   = NewHTTPError(http.StatusForbidden)
	ErrMethodNotAllowed            = NewHTTPError(http.StatusMethodNotAllowed)
	ErrStatusRequestEntityTooLarge = NewHTTPError(http.StatusRequestEntityTooLarge)
	ErrTooManyRequests             = NewHTTPError(http.StatusTooManyRequests)
	ErrBadRequest                  = NewHTTPError(http.StatusBadRequest)
	ErrBadGateway                  = NewHTTPError(http.StatusBadGateway)
	ErrInternalServerError         = NewHTTPError(http.StatusInternalServerError)
	ErrRequestTimeout              = NewHTTPError(http.StatusRequestTimeout)
	ErrServiceUnavailable          = NewHTTPError(http.StatusServiceUnavailable)
	ErrValidatorNotRegistered      = errors.New("validator not registered")
	ErrRendererNotRegistered       = errors.New("renderer not registered")
	ErrInvalidRedirectCode         = errors.New("invalid redirect status code")
	ErrCookieNotFound              = errors.New("cookie not found")
)

Errors

View Source
var (
	NotFoundHandler = func(c Context) error {
		return ErrNotFound
	}

	MethodNotAllowedHandler = func(c Context) error {
		return ErrMethodNotAllowed
	}
)

Error handlers

Functions

func DefaultSkipper added in v0.0.3

func DefaultSkipper(Context) bool

DefaultSkipper returns false which processes the middleware.

Types

type BindUnmarshaler

type BindUnmarshaler interface {
	// UnmarshalParam decodes and assigns a value from an form or query param.
	UnmarshalParam(param string) error
}

BindUnmarshaler is the interface used to wrap the UnmarshalParam method.

type Binder

type Binder interface {
	Bind(i interface{}, c Context) error
}

Binder is the interface that wraps the Bind method.

type Context

type Context interface {
	// Request returns `*http.Request`.
	Request() *http.Request

	// SetRequest sets `*http.Request`.
	SetRequest(r *http.Request)

	// Response returns `*Response`.
	Response() *Response

	// Path returns the registered path for the handler.
	Path() string

	// SetPath sets the registered path for the handler.
	SetPath(p string)

	// Param returns path parameter by name.
	Param(name string) string

	// ParamNames returns path parameter names.
	ParamNames() []string

	// SetParamNames sets path parameter names.
	SetParamNames(names ...string)

	// ParamValues returns path parameter values.
	ParamValues() []string

	// SetParamValues sets path parameter values.
	SetParamValues(values ...string)

	// QueryParam returns the query param for the provided name.
	QueryParam(name string) string

	// QueryParams returns the query parameters as `url.Values`.
	QueryParams() url.Values

	// QueryString returns the URL query string.
	QueryString() string

	// FormValue returns the form field value for the provided name.
	FormValue(name string) string

	// FormParams returns the form parameters as `url.Values`.
	FormParams() (url.Values, error)

	// FormFile returns the multipart form file for the provided name.
	FormFile(name string) (*multipart.FileHeader, error)

	// MultipartForm returns the multipart form.
	MultipartForm() (*multipart.Form, error)

	// Cookie returns the named cookie provided in the request.
	Cookie(name string) (*http.Cookie, error)

	// SetCookie adds a `Set-Cookie` header in HTTP response.
	SetCookie(cookie *http.Cookie)

	// Cookies returns the HTTP cookies sent with the request.
	Cookies() []*http.Cookie

	// Get retrieves data from the context.
	Get(key string) interface{}

	// Set saves data in the context.
	Set(key string, val interface{})

	// Bind binds the request body into provided type `i`. The default binder
	// does it based on Content-Type header.
	Bind(i interface{}) error

	// Render renders a template with data and sends a text/html response with status
	// code. Renderer must be registered using `nio.Renderer`.
	Render(code int, name string, data interface{}) error

	// HTML sends an HTTP response with status code.
	HTML(code int, html string) error

	// HTMLBlob sends an HTTP blob response with status code.
	HTMLBlob(code int, b []byte) error

	// String sends a string response with status code.
	String(code int, s string) error

	// JSON sends a JSON response with status code.
	JSON(code int, i interface{}) error

	// JSONPretty sends a pretty-print JSON with status code.
	JSONPretty(code int, i interface{}, indent string) error

	// JSONBlob sends a JSON blob response with status code.
	JSONBlob(code int, b []byte) error

	// JSONP sends a JSONP response with status code. It uses `callback` to construct
	// the JSONP payload.
	JSONP(code int, callback string, i interface{}) error

	// JSONPBlob sends a JSONP blob response with status code. It uses `callback`
	// to construct the JSONP payload.
	JSONPBlob(code int, callback string, b []byte) error

	// XML sends an XML response with status code.
	XML(code int, i interface{}) error

	// XMLPretty sends a pretty-print XML with status code.
	XMLPretty(code int, i interface{}, indent string) error

	// XMLBlob sends an XML blob response with status code.
	XMLBlob(code int, b []byte) error

	// Blob sends a blob response with status code and content type.
	Blob(code int, contentType string, b []byte) error

	// Stream sends a streaming response with status code and content type.
	Stream(code int, contentType string, r io.Reader) error

	// File sends a response with the content of the file.
	File(file string) error

	// Attachment sends a response as attachment, prompting client to save the
	// file.
	Attachment(file string, name string) error

	// Inline sends a response as inline, opening the file in the browser.
	Inline(file string, name string) error

	// NoContent sends a response with no body and a status code.
	NoContent(code int) error

	// Redirect redirects the request to a provided URL with status code.
	Redirect(code int, url string) error

	// Error invokes the registered HTTP error handler. Generally used by middleware.
	Error(err error)

	// Handler returns the matched handler by router.
	Handler() HandlerFunc

	// SetHandler sets the matched handler by router.
	SetHandler(h HandlerFunc)

	// Nio returns the `Nio` instance.
	Nio() *Nio

	// Logger returns default logger
	Logger() log.Logger
}

Context represents the context of the current HTTP request. It holds request and response objects, path, path parameters, data and registered handler.

type DefaultBinder

type DefaultBinder struct{}

DefaultBinder is the default implementation of the Binder interface.

func (*DefaultBinder) Bind

func (b *DefaultBinder) Bind(i interface{}, c Context) (err error)

Bind implements the `Binder#Bind` function.

type Group

type Group struct {
	// contains filtered or unexported fields
}

Group is a set of sub-routes for a specified route. It can be used for inner routes that share a common middleware or functionality that should be separate from the parent nio instance while still inheriting from it.

func (*Group) Add

func (g *Group) Add(method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) *Route

Add implements `Nio#Add()` for sub-routes within the Group.

func (*Group) Any

func (g *Group) Any(path string, handler HandlerFunc, middleware ...MiddlewareFunc) []*Route

Any implements `Nio#Any()` for sub-routes within the Group.

func (*Group) CONNECT

func (g *Group) CONNECT(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

CONNECT implements `Nio#CONNECT()` for sub-routes within the Group.

func (*Group) DELETE

func (g *Group) DELETE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

DELETE implements `Nio#DELETE()` for sub-routes within the Group.

func (*Group) File

func (g *Group) File(path, file string)

File implements `Nio#File()` for sub-routes within the Group.

func (*Group) GET

func (g *Group) GET(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

GET implements `Nio#GET()` for sub-routes within the Group.

func (*Group) Group

func (g *Group) Group(prefix string, middleware ...MiddlewareFunc) *Group

Group creates a new sub-group with prefix and optional sub-group-level middleware.

func (*Group) HEAD

func (g *Group) HEAD(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

HEAD implements `Nio#HEAD()` for sub-routes within the Group.

func (*Group) Match

func (g *Group) Match(methods []string, path string, handler HandlerFunc, middleware ...MiddlewareFunc) []*Route

Match implements `Nio#Match()` for sub-routes within the Group.

func (*Group) OPTIONS

func (g *Group) OPTIONS(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

OPTIONS implements `Nio#OPTIONS()` for sub-routes within the Group.

func (*Group) PATCH

func (g *Group) PATCH(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

PATCH implements `Nio#PATCH()` for sub-routes within the Group.

func (*Group) POST

func (g *Group) POST(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

POST implements `Nio#POST()` for sub-routes within the Group.

func (*Group) PUT

func (g *Group) PUT(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

PUT implements `Nio#PUT()` for sub-routes within the Group.

func (*Group) Static

func (g *Group) Static(prefix, root string)

Static implements `Nio#Static()` for sub-routes within the Group.

func (*Group) TRACE

func (g *Group) TRACE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

TRACE implements `Nio#TRACE()` for sub-routes within the Group.

func (*Group) Use

func (g *Group) Use(middleware ...MiddlewareFunc)

Use implements `Nio#Use()` for sub-routes within the Group.

type HTTPError

type HTTPError struct {
	Code     int
	Message  interface{}
	Internal error // Stores the error returned by an external dependency
}

HTTPError represents an error that occurred while handling a request.

func NewHTTPError

func NewHTTPError(code int, message ...interface{}) *HTTPError

NewHTTPError creates a new HTTPError instance.

func (*HTTPError) Error

func (he *HTTPError) Error() string

Error makes it compatible with `error` interface.

func (*HTTPError) SetInternal

func (he *HTTPError) SetInternal(err error) *HTTPError

SetInternal sets internal error on HTTPError

type HTTPErrorHandler

type HTTPErrorHandler func(error, Context)

HTTPErrorHandler is a centralized HTTP error handler.

type HandlerFunc

type HandlerFunc func(Context) error

HandlerFunc defines a function to serve HTTP requests.

func WrapHandler

func WrapHandler(h http.Handler) HandlerFunc

WrapHandler wraps `http.Handler` into `nio.HandlerFunc`.

type MiddlewareFunc

type MiddlewareFunc func(HandlerFunc) HandlerFunc

MiddlewareFunc defines a function to process middleware.

func WrapMiddleware

func WrapMiddleware(m func(http.Handler) http.Handler) MiddlewareFunc

WrapMiddleware wraps `func(http.Handler) http.Handler` into `nio.MiddlewareFunc`

type Nio

type Nio struct {
	Debug bool
	// contains filtered or unexported fields
}

Nio is the top-level framework instance.

func New

func New(opt ...Option) (e *Nio)

New creates an instance of nio.

func (*Nio) Add

func (e *Nio) Add(method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) *Route

Add registers a new route for an HTTP method and path with matching handler in the router with optional route-level middleware.

func (*Nio) Any

func (e *Nio) Any(path string, handler HandlerFunc, middleware ...MiddlewareFunc) []*Route

Any registers a new route for all HTTP methods and path with matching handler in the router with optional route-level middleware.

func (*Nio) CONNECT

func (e *Nio) CONNECT(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

CONNECT registers a new CONNECT route for a path with matching handler in the router with optional route-level middleware.

func (*Nio) DELETE

func (e *Nio) DELETE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

DELETE registers a new DELETE route for a path with matching handler in the router with optional route-level middleware.

func (*Nio) File

func (e *Nio) File(path, file string, m ...MiddlewareFunc) *Route

File registers a new route with path to serve a static file with optional route-level middleware.

func (*Nio) GET

func (e *Nio) GET(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

GET registers a new GET route for a path with matching handler in the router with optional route-level middleware.

func (*Nio) Group

func (e *Nio) Group(prefix string, m ...MiddlewareFunc) (g *Group)

Group creates a new router group with prefix and optional group-level middleware.

func (*Nio) HEAD

func (e *Nio) HEAD(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

HEAD registers a new HEAD route for a path with matching handler in the router with optional route-level middleware.

func (*Nio) Logger

func (e *Nio) Logger() log.Logger

Logger returns nio logger

func (*Nio) Match

func (e *Nio) Match(methods []string, path string, handler HandlerFunc, middleware ...MiddlewareFunc) []*Route

Match registers a new route for multiple HTTP methods and path with matching handler in the router with optional route-level middleware.

func (*Nio) NewContext

func (e *Nio) NewContext(r *http.Request, w http.ResponseWriter) Context

NewContext returns a Context instance.

func (*Nio) OPTIONS

func (e *Nio) OPTIONS(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

OPTIONS registers a new OPTIONS route for a path with matching handler in the router with optional route-level middleware.

func (*Nio) PATCH

func (e *Nio) PATCH(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

PATCH registers a new PATCH route for a path with matching handler in the router with optional route-level middleware.

func (*Nio) POST

func (e *Nio) POST(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

POST registers a new POST route for a path with matching handler in the router with optional route-level middleware.

func (*Nio) PUT

func (e *Nio) PUT(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

PUT registers a new PUT route for a path with matching handler in the router with optional route-level middleware.

func (*Nio) Pre

func (e *Nio) Pre(middleware ...MiddlewareFunc)

Pre adds middleware to the chain which is run before router.

func (*Nio) Reverse

func (e *Nio) Reverse(name string, params ...interface{}) string

Reverse generates an URL from route name and provided parameters.

func (*Nio) Routes

func (e *Nio) Routes() []*Route

Routes returns the registered routes.

func (*Nio) ServeHTTP

func (e *Nio) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements `http.Handler` interface, which serves HTTP requests.

func (*Nio) Static

func (e *Nio) Static(prefix, root string) *Route

Static registers a new route with path prefix to serve static files from the provided root directory.

func (*Nio) TRACE

func (e *Nio) TRACE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route

TRACE registers a new TRACE route for a path with matching handler in the router with optional route-level middleware.

func (*Nio) URI

func (e *Nio) URI(handler HandlerFunc, params ...interface{}) string

URI generates a URI from handler.

func (*Nio) URL

func (e *Nio) URL(h HandlerFunc, params ...interface{}) string

URL is an alias for `URI` function.

func (*Nio) Use

func (e *Nio) Use(middleware ...MiddlewareFunc)

Use adds middleware to the chain which is run after router.

type Option

type Option func(*options)

A Option sets options such as credentials, tls, etc.

func WithBinder added in v1.0.0

func WithBinder(binder Binder) Option

WithBinder allows to override default nio binder

func WithHTTPErrorHandler added in v1.0.0

func WithHTTPErrorHandler(handler HTTPErrorHandler) Option

WithHTTPErrorHandler allows to override default nio global error handler

func WithLogger added in v1.0.0

func WithLogger(logger log.Logger) Option

WithLogger allows to override default nio logger

func WithRenderer added in v1.0.0

func WithRenderer(renderer Renderer) Option

WithRenderer allows to register nio view renderer

type Renderer

type Renderer interface {
	Render(io.Writer, string, interface{}, Context) error
}

Renderer is the interface that wraps the Render function.

type Response

type Response struct {
	Writer    http.ResponseWriter
	Status    int
	Size      int64
	Committed bool
	// contains filtered or unexported fields
}

Response wraps an http.ResponseWriter and implements its interface to be used by an HTTP handler to construct an HTTP response. See: https://golang.org/pkg/net/http/#ResponseWriter

func NewResponse

func NewResponse(w http.ResponseWriter) (r *Response)

NewResponse creates a new instance of Response.

func (*Response) After

func (r *Response) After(fn func())

After registers a function which is called just after the response is written. If the `Content-Length` is unknown, none of the after function is executed.

func (*Response) Before

func (r *Response) Before(fn func())

Before registers a function which is called just before the response is written.

func (*Response) CloseNotify

func (r *Response) CloseNotify() <-chan bool

CloseNotify implements the http.CloseNotifier interface to allow detecting when the underlying connection has gone away. This mechanism can be used to cancel long operations on the server if the client has disconnected before the response is ready. See http.CloseNotifier(https://golang.org/pkg/net/http/#CloseNotifier)

func (*Response) Flush

func (r *Response) Flush()

Flush implements the http.Flusher interface to allow an HTTP handler to flush buffered data to the client. See http.Flusher(https://golang.org/pkg/net/http/#Flusher)

func (*Response) Header

func (r *Response) Header() http.Header

Header returns the header map for the writer that will be sent by WriteHeader. Changing the header after a call to WriteHeader (or Write) has no effect unless the modified headers were declared as trailers by setting the "Trailer" header before the call to WriteHeader (see example) To suppress implicit response headers, set their value to nil. Example: https://golang.org/pkg/net/http/#example_ResponseWriter_trailers

func (*Response) Hijack

func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error)

Hijack implements the http.Hijacker interface to allow an HTTP handler to take over the connection. See http.Hijacker(https://golang.org/pkg/net/http/#Hijacker)

func (*Response) Write

func (r *Response) Write(b []byte) (n int, err error)

Write writes the data to the connection as part of an HTTP reply.

func (*Response) WriteHeader

func (r *Response) WriteHeader(code int)

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.

type Route

type Route struct {
	Method string `json:"method"`
	Path   string `json:"path"`
	Name   string `json:"name"`
}

Route contains a handler and information for matching against requests.

type Skipper added in v0.0.3

type Skipper func(Context) bool

Skipper defines a function to skip middleware. Returning true skips processing the middleware.

Directories

Path Synopsis
examples
internal
Package log implements default nio logger.
Package log implements default nio logger.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL