router

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 13 Imported by: 9

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitRoutes added in v0.11.0

func InitRoutes(cb func(r *Router)) kernel.KernelOption

Types

type Attr added in v0.8.0

type Attr struct {
	Key   string
	Value string
}

func ToAttrs added in v0.8.0

func ToAttrs(params []any) ([]*Attr, error)

type MiddlewareFunc

type MiddlewareFunc = mux.MiddlewareFunc

type Route added in v0.8.0

type Route struct {
	Path   string
	Method string
	// contains filtered or unexported fields
}

func (*Route) Name added in v0.8.0

func (r *Route) Name(name string) *Route

type Router

type Router struct {
	// contains filtered or unexported fields
}
Example
package main

import (
	"github.com/abibby/salusa/request"
	"github.com/abibby/salusa/router"
)

func main() {
	r := router.New()

	r.Group("/test", func(r *router.Router) {
		r.Get("/", request.Handler(func(r *any) (any, error) {
			return nil, nil
		}))
	})
}
Output:

func New

func New() *Router

func (*Router) Delete

func (r *Router) Delete(path string, handler http.Handler) *Route

func (*Router) Get

func (r *Router) Get(path string, handler http.Handler) *Route

func (*Router) Group

func (r *Router) Group(prefix string, cb func(r *Router))

func (*Router) Handle

func (r *Router) Handle(p string, handler http.Handler) *Route

func (*Router) Patch

func (r *Router) Patch(path string, handler http.Handler) *Route

func (*Router) Post

func (r *Router) Post(path string, handler http.Handler) *Route

func (*Router) PrintRoutes added in v0.8.0

func (r *Router) PrintRoutes()

func (*Router) Put

func (r *Router) Put(path string, handler http.Handler) *Route

func (*Router) Register added in v0.8.0

func (r *Router) Register(ctx context.Context)

func (*Router) Routes added in v0.8.0

func (r *Router) Routes() []*Route

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Router) Use

func (r *Router) Use(middleware MiddlewareFunc)

func (*Router) Validate added in v0.11.0

func (r *Router) Validate(ctx context.Context) error

func (*Router) WithDependencyProvider added in v0.8.0

func (r *Router) WithDependencyProvider(dp *di.DependencyProvider)

type SalusaResolver added in v0.8.0

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

func NewResolver added in v0.8.0

func NewResolver(origin string, r *Router) *SalusaResolver

func (*SalusaResolver) Resolve added in v0.8.0

func (r *SalusaResolver) Resolve(name string, params ...any) string

func (*SalusaResolver) ResolveHandler added in v0.8.0

func (r *SalusaResolver) ResolveHandler(h http.Handler, params ...any) string

type URLResolver added in v0.8.0

type URLResolver interface {
	Resolve(name string, params ...any) string
	ResolveHandler(h http.Handler, params ...any) string
}

type WithDependencyProvider added in v0.8.0

type WithDependencyProvider interface {
	WithDependencyProvider(dp *di.DependencyProvider)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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