interceptor

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeJSON     = "application/json"
	ContentTypeHTML     = "text/html"
	ContentTypeImagePNG = "image/png"
	ContentTypeCSS      = "text/css"
	ContentTypeJS       = "text/javascript"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpAnswer

type HttpAnswer struct {
	ResponseCode int
	Content      interface{}
	ContentType  string
}

func (*HttpAnswer) Send

func (answer *HttpAnswer) Send(w http.ResponseWriter)

type HttpRegexp

type HttpRegexp struct {
	List map[string]*regexp.Regexp
}

Регулярные выражения для проверки роутов

func (*HttpRegexp) Add

func (reg *HttpRegexp) Add(pattern, regExpPattern string)

func (*HttpRegexp) Init

func (reg *HttpRegexp) Init()

type HttpRoute

type HttpRoute struct {
	Method string
	URI    string
	F      func(http.ResponseWriter, *http.Request)
}

Один Роут и методы его сравнения

func (*HttpRoute) MatchMethod

func (route *HttpRoute) MatchMethod(r *http.Request) bool

func (*HttpRoute) MatchURI

func (route *HttpRoute) MatchURI(r *http.Request, regexp HttpRegexp) bool

type HttpRouter

type HttpRouter struct {
	Routes                []HttpRoute
	DefaultNotFoundAnswer HttpAnswer
	HttpRegexp
}

func (*HttpRouter) HandleFunc

func (router *HttpRouter) HandleFunc(method, uri string, f func(http.ResponseWriter, *http.Request))

func (*HttpRouter) Init

func (router *HttpRouter) Init()

func (*HttpRouter) ServeHTTP

func (router *HttpRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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