httpserver

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDescription

func WithDescription(desc string) interface{}

WithDescription for Route, description for this route

func WithFileSystem

func WithFileSystem(fs http.FileSystem) interface{}

WithFileSystem for Static And File

func WithFileSystemPath

func WithFileSystemPath(root string) interface{}

WithFileSystemPath for Static And File

func WithHide

func WithHide(hide bool) interface{}

WithHide for Route, not print this route

func WithIntercepter

func WithIntercepter(fn func(handler func(ctx Context) error) func(ctx Context) error) interface{}

WithIntercepter for Router

Types

type Context

type Context interface {
	SetAttribute(key string, val interface{})
	Attribute(key string) interface{}
	Attributes() map[string]interface{}
	Request() *http.Request
	ResponseWriter() http.ResponseWriter
	Param(name string) string
	ParamNames() []string
}

Context handler context.

type Intercepter

type Intercepter func(handler func(ctx Context) error) func(ctx Context) error

Intercepter .

type Router

type Router interface {
	GET(path string, handler interface{}, options ...interface{})
	POST(path string, handler interface{}, options ...interface{})
	DELETE(path string, handler interface{}, options ...interface{})
	PUT(path string, handler interface{}, options ...interface{})
	PATCH(path string, handler interface{}, options ...interface{})
	HEAD(path string, handler interface{}, options ...interface{})
	CONNECT(path string, handler interface{}, options ...interface{})
	OPTIONS(path string, handler interface{}, options ...interface{})
	TRACE(path string, handler interface{}, options ...interface{})

	Any(path string, handler interface{}, options ...interface{})
	Static(prefix, root string, options ...interface{})
	File(path, filepath string, options ...interface{})

	Add(method, path string, handler interface{}, options ...interface{})
}

Router .

Jump to

Keyboard shortcuts

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