router

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package router implements the router

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertRouteToRouteName

func ConvertRouteToRouteName(route string) (string, error)

Types

type HandlerFn

type HandlerFn func(w http.ResponseWriter, r *http.Request) error

func (HandlerFn) ServeHTTP

func (h HandlerFn) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Middlewares

type Middlewares []func(http.ResponseWriter, *http.Request)

type Mux

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

func NewMux

func NewMux() *Mux

func (*Mux) Connect

func (m *Mux) Connect(ri *RouteInfo, handlerFn HandlerFn)

func (*Mux) Delete

func (m *Mux) Delete(ri *RouteInfo, handlerFn HandlerFn)

func (*Mux) Get

func (m *Mux) Get(ri *RouteInfo, handlerFn HandlerFn)

func (*Mux) Handle

func (m *Mux) Handle(ri *RouteInfo, handler http.Handler)

func (*Mux) HandleFunc

func (m *Mux) HandleFunc(ri *RouteInfo, handlerFn HandlerFn)

func (*Mux) Head

func (m *Mux) Head(ri *RouteInfo, handlerFn HandlerFn)

func (*Mux) Method

func (m *Mux) Method(ri *RouteInfo, handler http.Handler)

func (*Mux) MethodFunc

func (m *Mux) MethodFunc(ri *RouteInfo, handlerFn HandlerFn)

func (*Mux) Options

func (m *Mux) Options(ri *RouteInfo, handlerFn HandlerFn)

func (*Mux) Patch

func (m *Mux) Patch(ri *RouteInfo, handlerFn HandlerFn)

func (*Mux) Post

func (m *Mux) Post(ri *RouteInfo, handlerFn HandlerFn)

func (*Mux) Put

func (m *Mux) Put(ri *RouteInfo, handlerFn HandlerFn)

func (*Mux) ServeHTTP

func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Mux) Trace

func (m *Mux) Trace(ri *RouteInfo, handlerFn HandlerFn)

func (*Mux) Use

func (m *Mux) Use(middlewares ...func(http.Handler) http.Handler)

type RouteCache

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

func NewRouteCacheService

func NewRouteCacheService(opts ...RouteCacheOpt) (*RouteCache, error)

func (*RouteCache) AddRouteInfo

func (r *RouteCache) AddRouteInfo(routeInfo *RouteInfo) error

func (*RouteCache) All

func (r *RouteCache) All() (map[string]string, error)

func (*RouteCache) GetPath

func (r *RouteCache) GetPath(name string) (string, error)

func (*RouteCache) GetRouteInfo

func (r *RouteCache) GetRouteInfo(name string) (*RouteInfo, error)

type RouteCacheOpt

type RouteCacheOpt func(*RouteCache)

func WithStore

func WithStore(store storage.Storer) RouteCacheOpt

func WithTTL

func WithTTL(ttl time.Duration) RouteCacheOpt

type RouteCacher

type RouteCacher interface {
	AddRouteInfo(*RouteInfo) error
	GetPath(string) (string, error)
	GetRouteInfo(string) (*RouteInfo, error)
	All() (map[string]string, error)
}

type RouteInfo

type RouteInfo struct {
	Method      string
	Name        string
	Path        string
	Description string
	Title       string
}

func NewRouteInfo

func NewRouteInfo(opts ...RouteInfoOpt) (*RouteInfo, error)

type RouteInfoOpt

type RouteInfoOpt func(r *RouteInfo)

func Description

func Description(description string) RouteInfoOpt

func Method

func Method(method string) RouteInfoOpt

func Name

func Name(name string) RouteInfoOpt

func Path

func Path(path string) RouteInfoOpt

func Title

func Title(title string) RouteInfoOpt

type Router

type Router interface {
	Handle(ri *RouteInfo, handler http.Handler)
	HandleFunc(ri *RouteInfo, handlerFn HandlerFn)
	Method(ri *RouteInfo, handler http.Handler)
	MethodFunc(ri *RouteInfo, handlerFn HandlerFn)
	Get(ri *RouteInfo, handlerFn HandlerFn)
	Post(ri *RouteInfo, handlerFn HandlerFn)
	Put(ri *RouteInfo, handlerFn HandlerFn)
	Delete(ri *RouteInfo, handlerFn HandlerFn)
	Patch(ri *RouteInfo, handlerFn HandlerFn)
	Options(ri *RouteInfo, handlerFn HandlerFn)
	Head(ri *RouteInfo, handlerFn HandlerFn)
	Trace(ri *RouteInfo, handlerFn HandlerFn)
	Connect(ri *RouteInfo, handlerFn HandlerFn)
}

Jump to

Keyboard shortcuts

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