framework

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValues

func GetValues(ctx context.Context) (map[string]string, bool)

GetValues gets the match pattern values from the http.Request context

Types

type Framework

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

Framework is a web framework main data structure

func New

func New() *Framework

New is the Framework constructor

func (*Framework) Attach

func (fw *Framework) Attach(middlewares ...middleware.Middleware) *Framework

Attach adds middleware to the chain

func (*Framework) Clear

func (fw *Framework) Clear()

Clear clears all handlers for all methods

func (*Framework) Delete

func (fw *Framework) Delete(path string, handler http.HandlerFunc)

Delete adds handler for DELETE requests

func (*Framework) Get

func (fw *Framework) Get(path string, handler http.HandlerFunc)

Get adds handler for GET requests

func (*Framework) Head

func (fw *Framework) Head(path string, handler http.HandlerFunc)

Head adds handler for PATCH requests

func (*Framework) Options

func (fw *Framework) Options(path string, handler http.HandlerFunc)

Options adds handler for PATCH requests

func (*Framework) Patch

func (fw *Framework) Patch(path string, handler http.HandlerFunc)

Patch adds handler for PATCH requests

func (*Framework) Post

func (fw *Framework) Post(path string, handler http.HandlerFunc)

Post adds handler for POST requests

func (*Framework) Put

func (fw *Framework) Put(path string, handler http.HandlerFunc)

Put adds handler for PUT requests

func (*Framework) ServeHTTP

func (fw *Framework) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is the implementation of the http.Handler interface It combines the chain and serves the HTTP requests.

func (*Framework) WithPrefix

func (fw *Framework) WithPrefix(prefix string, route Route) *Framework

WithPrefix registers paths with given prefix.

type Route

type Route func()

Route callback function

type Router

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

Router is a URI path router object

func NewRouter

func NewRouter() *Router

NewRouter creates a new Router instance

func (*Router) Handle

func (rt *Router) Handle(path string, handler http.HandlerFunc) (err error)

Handle add a route and a handler

func (*Router) Lookup

func (rt *Router) Lookup(path string) (http.HandlerFunc, map[string]string, error)

Lookup for a handler in the path, a handler, pattern values and error is returned.

func (*Router) RouterHandler

func (rt *Router) RouterHandler(w http.ResponseWriter, r *http.Request)

RouterHandler is a http.HandlerFunc router that dispatches the request based on saved routes and handlers

Jump to

Keyboard shortcuts

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