webrouter

package module
v0.0.0-...-e49551c Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: Apache-2.0 Imports: 11 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultRouter = NewManager()
	DefaultServer = http.Server{
		ReadTimeout:  1 * time.Minute,
		WriteTimeout: 1 * time.Minute,
	}
)
View Source
var (
	CtHTMLHeader = Header{"Content-Type", []string{"text/html; charset=utf-8"}}
)

Functions

func ClearAfterMethodName

func ClearAfterMethodName()

func ClearBeforeMethodName

func ClearBeforeMethodName()

func Close

func Close()

func Error

func Error(w http.ResponseWriter, error string, code int, headers ...Header)

func GetAfterMethodName

func GetAfterMethodName() []string

func GetBeforeMethodName

func GetBeforeMethodName() []string

func GetDefaultMethodName

func GetDefaultMethodName() string

func GetDelimiterStyle

func GetDelimiterStyle() byte

func GetFilterMethodNameAndHTTPMethodName

func GetFilterMethodNameAndHTTPMethodName(methodName string) (string, string)

func GetFilterPrefix

func GetFilterPrefix() string

func GetHTTPMethodNamePrefix

func GetHTTPMethodNamePrefix() string

func Handle

func Handle(pattern string, handler http.Handler)

func HandleFunc

func HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))

func Handler

func Handler(req *http.Request) (h http.Handler, pattern string)

func Injector

func Injector(name, follower string, priority uint, handler func(http.ResponseWriter, *http.Request) bool)

func ListenAndServe

func ListenAndServe(addr string, handler http.Handler) error

func ListenAndServeTLS

func ListenAndServeTLS(addr, certFile, keyFile string, handler http.Handler) error

func MakePattern

func MakePattern(method string) string

func NotFoundHandler

func NotFoundHandler(error string)

func NotFoundHtmlHandler

func NotFoundHtmlHandler(error string)

func Register

func Register(patternRoot string, i interface{})

func Registers

func Registers() map[string]register

func Releasor

func Releasor(name, leader string, lag uint, handler func(http.ResponseWriter, *http.Request) bool)

func ServeHTTP

func ServeHTTP(w http.ResponseWriter, req *http.Request)

func SetAfterMethodName

func SetAfterMethodName(methodName string)

func SetBeforeMethodName

func SetBeforeMethodName(methodName string)

func SetCloser

func SetCloser(fn func())

func SetDefaultMethodName

func SetDefaultMethodName(methodName string)

func SetDelimiterStyle

func SetDelimiterStyle(delimiterStyle byte)

func SetFilterPrefix

func SetFilterPrefix(filterPrefix string)

func SetHTTPMethodNamePrefix

func SetHTTPMethodNamePrefix(methodNamePrefix string)

Types

type Header struct {
	Key     string
	Headers []string
}

type Manager

type Manager struct {
	*http.ServeMux
	// contains filtered or unexported fields
}

func NewManager

func NewManager() *Manager

func (*Manager) ClearAfterMethodName

func (rm *Manager) ClearAfterMethodName() *Manager

func (*Manager) ClearBeforeMethodName

func (rm *Manager) ClearBeforeMethodName() *Manager

func (*Manager) Close

func (rm *Manager) Close()

func (*Manager) GetAfterMethodName

func (rm *Manager) GetAfterMethodName() []string

func (*Manager) GetBeforeMethodName

func (rm *Manager) GetBeforeMethodName() []string

func (*Manager) GetDefaultMethodName

func (rm *Manager) GetDefaultMethodName() string

func (*Manager) GetDelimiterStyle

func (rm *Manager) GetDelimiterStyle() byte

func (*Manager) GetFilterMethodNameAndHTTPMethodName

func (rm *Manager) GetFilterMethodNameAndHTTPMethodName(methodName string) (filterMethodName, httpMethodName string)

func (*Manager) GetFilterPrefix

func (rm *Manager) GetFilterPrefix() string

func (*Manager) GetHTTPMethodNamePrefix

func (rm *Manager) GetHTTPMethodNamePrefix() string

func (*Manager) Handler

func (rm *Manager) Handler(r *http.Request) (h http.Handler, pattern string)

func (*Manager) Injector

func (rm *Manager) Injector(name, follower string, priority uint, handler func(http.ResponseWriter, *http.Request) bool)

func (*Manager) NotFoundHandler

func (rm *Manager) NotFoundHandler(errstr string)

func (*Manager) NotFoundHtmlHandler

func (rm *Manager) NotFoundHtmlHandler(errstr string)

func (*Manager) Register

func (rm *Manager) Register(patternRoot string, i interface{})

Priority:

1. [<beforeMethodName>_method] | [beforeMethodName]

2. [method]

3. [http_<method>_method]

4. [<afterMethodName>_method] | [afterMethodName]

func (*Manager) Registers

func (rm *Manager) Registers() map[string]register

func (*Manager) Releasor

func (rm *Manager) Releasor(name, leader string, lag uint, handler func(http.ResponseWriter, *http.Request) bool)

func (*Manager) ServeHTTP

func (rm *Manager) ServeHTTP(w http.ResponseWriter, r *http.Request)

processing order: injector > handler > releasor

func (*Manager) SetAfterMethodName

func (rm *Manager) SetAfterMethodName(methodName string) *Manager

func (*Manager) SetBeforeMethodName

func (rm *Manager) SetBeforeMethodName(methodName string) *Manager

func (*Manager) SetCloser

func (rm *Manager) SetCloser(fn func())

func (*Manager) SetDefaultMethodName

func (rm *Manager) SetDefaultMethodName(methodName string) *Manager

func (*Manager) SetDelimiterStyle

func (rm *Manager) SetDelimiterStyle(delimiterStyle byte) *Manager

func (*Manager) SetFilterPrefix

func (rm *Manager) SetFilterPrefix(filterPrefix string) *Manager

if filterPrefix value is '@' that mean not to filter, but it is has hidden danger, so you kown what to do.

func (*Manager) SetHTTPMethodNamePrefix

func (rm *Manager) SetHTTPMethodNamePrefix(methodNamePrefix string) *Manager

type ResponseWriter

type ResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func (*ResponseWriter) GetData

func (rw *ResponseWriter) GetData(key string) (interface{}, bool)

func (*ResponseWriter) GetResData

func (rw *ResponseWriter) GetResData() []byte

func (*ResponseWriter) Header

func (rw *ResponseWriter) Header() http.Header

func (*ResponseWriter) Hijack

func (rw *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

func (*ResponseWriter) SetData

func (rw *ResponseWriter) SetData(key string, value interface{})

func (*ResponseWriter) SetGetResData

func (rw *ResponseWriter) SetGetResData(getResData bool)

func (*ResponseWriter) Write

func (rw *ResponseWriter) Write(b []byte) (int, error)

func (*ResponseWriter) WriteHeader

func (rw *ResponseWriter) WriteHeader(statusCode int)

Jump to

Keyboard shortcuts

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