router

package
v0.0.0-...-fe14df0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileHandler

type FileHandler struct {
	MimeType string
	// contains filtered or unexported fields
}

FileHandler handles the reading of the file

func (*FileHandler) FullPath

func (fh *FileHandler) FullPath() string

FullPath returns the full path of the file.

func (*FileHandler) ReadFile

func (fh *FileHandler) ReadFile() ([]byte, error)

ReadFile reads the file of the provided path. Returns an error if it does not exist.

type HandleFunc

type HandleFunc func(req *http.Request, res *http.Response)

HandleFunc is function that represents the handler for a HTTP-Endpoint

type Route

type Route struct {
	Get    []HandleFunc
	Post   []HandleFunc
	Put    []HandleFunc
	Delete []HandleFunc
	Patch  []HandleFunc
	// contains filtered or unexported fields
}

Route represents a node in a http-router, and contains http-method-implementation

func NewRoot

func NewRoot() *Route

NewRoot creates a new Route with the path "/".

func (*Route) AppendRouter

func (r *Route) AppendRouter(router *Router)

AppendRouter adds all the routes inside a given router to the route.

func (*Route) GetHandlers

func (r *Route) GetHandlers(method string) []HandleFunc

GetHandlers gets the handlers for a given method

func (*Route) Search

func (r *Route) Search(path string) (match bool, route *Route, params map[string]string, fh *FileHandler)

Search searches for a route on a specific path on the route.

func (*Route) String

func (r *Route) String() string

type Router

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

Router manages routes for given http-endpoints

func NewRouter

func NewRouter(basePath string) *Router

NewRouter creates a new router to build routes with.

func (*Router) Delete

func (r *Router) Delete(path string, funcs ...HandleFunc)

Delete initializes a DELETE-endpoint at given path.

func (*Router) Get

func (r *Router) Get(path string, funcs ...HandleFunc)

Get initializes a GET-endpoint at given path.

func (*Router) Patch

func (r *Router) Patch(path string, funcs ...HandleFunc)

Patch initializes a PATCH-endpoint at given path.

func (*Router) Post

func (r *Router) Post(path string, funcs ...HandleFunc)

Post initializes a POST-endpoint at given path.

func (*Router) Put

func (r *Router) Put(path string, funcs ...HandleFunc)

Put initializes a PUT-endpoint at given path.

func (*Router) Root

func (r *Router) Root() *Route

Root returns the root of the router.

func (*Router) Static

func (r *Router) Static(path string, relativePath string)

Static initializes a static route for handling searches for static files.

Jump to

Keyboard shortcuts

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