router

package
v0.24.3 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RESERVED_ENDPOINTS = map[string]struct{}{
	"public":  {},
	"private": {},
	"doc":     {},
	"docs":    {},
}

Functions

This section is empty.

Types

type EndPoint added in v0.23.24

type EndPoint struct {
	Depth    int
	Endpoint string
	// contains filtered or unexported fields
}

func NewEndPoint added in v0.23.24

func NewEndPoint(endpoint string) *EndPoint

func NewRootPoint added in v0.23.24

func NewRootPoint() *EndPoint

func (*EndPoint) Delete added in v0.23.24

func (a *EndPoint) Delete(h ...Handler)

func (*EndPoint) Get added in v0.23.24

func (a *EndPoint) Get(h ...Handler)

func (*EndPoint) Head added in v0.23.24

func (a *EndPoint) Head(h ...Handler)

func (*EndPoint) Patch added in v0.23.24

func (a *EndPoint) Patch(h ...Handler)

func (*EndPoint) Post added in v0.23.24

func (a *EndPoint) Post(h ...Handler)

func (*EndPoint) Put added in v0.23.24

func (a *EndPoint) Put(h ...Handler)

func (*EndPoint) Sub added in v0.23.24

func (a *EndPoint) Sub(e *EndPoint) *EndPoint

func (*EndPoint) URL added in v0.23.24

func (a *EndPoint) URL() string

type Handler added in v0.23.24

type Handler func(req *generated.Request, res *generated.Response) error

Handler définit le type de fonction qui implémente HandlerInterface.

type Router added in v0.23.24

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

Router represents your API. It manages the association of URL paths with their corresponding handlers based on HTTP methods like GET, POST, PUT, PATCH, and DELETE. The Router also keeps track of whether it is deprecated.

func MakeRouter added in v0.23.24

func MakeRouter() *Router

MakeRouter creates and returns a new instance of Router. This function initializes a Router with its default values.

Returns: - *Router: A new instance of Router.

func (*Router) Register added in v0.23.24

func (r *Router) Register(epi *EndPoint) error

func (*Router) Resolve added in v0.23.24

func (r *Router) Resolve(exchange *transport.Exchange)

Resolve process the request and applies appropriate handlers

This function takes a router and an exchange object. It resolves the endpoint from the request, then applies the corresponding handlers based on the request method.

Parameters: - exchange: *transport.Exchange The exchange object containing request and response.

Returns: - err: error The error encountered during processing, if any.

Jump to

Keyboard shortcuts

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