router

package
v0.0.0-...-13d35ee Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogRoutes

func LogRoutes(r *chi.Mux, logger *zap.Logger)

LogRoutes logs routing on Debug level when server is ONLINE

Example
logger, _ := zap.NewProduction()
defer logger.Sync()

mux := Setup()

LogRoutes(mux, logger)

srv := &http.Server{
	Handler:      mux,
	ReadTimeout:  5 * time.Second,
	WriteTimeout: 10 * time.Second,
	IdleTimeout:  15 * time.Second,
}
srv.ListenAndServe()

// Outputs:
// {"level":"debug","timestamp":"2020-05-21T22:07:12.091+0900","logger":"server/server.go:109","message":"Registering route","method":"GET","route":"/health"}
Output:

func Setup

func Setup(middlewares ...func(http.Handler) http.Handler) *chi.Mux

Setup a new go-chi router

Types

type Endpoint

type Endpoint struct {
	Middlewares []func(http.Handler) http.Handler
	Handler     http.HandlerFunc
}

Endpoint ...

type EndpointPattern

type EndpointPattern struct {
	Pattern   string
	Endpoints map[string]Endpoint
}

EndpointPattern ...

type Route

type Route struct {
	Middlewares []func(http.Handler) http.Handler
	Endpoints   []EndpointPattern
	SubRoutes   []SubRoute
}

Route ...

func New

func New(rt Route) *Route

New sets a Route

func (*Route) Build

func (rt *Route) Build(r *chi.Mux) (err error)

Build router

type SubRoute

type SubRoute struct {
	Pattern string
	Route   Route
}

SubRoute ...

Jump to

Keyboard shortcuts

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