web

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

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

Go to latest
Published: Sep 16, 2020 License: MIT Imports: 10 Imported by: 0

README

httpd

Documentation

Index

Constants

View Source
const (
	ReturnCodeSuccess = "success"
)

Variables

View Source
var ErrPageNotFound = Abort(http.StatusNotFound, "PageNotFound", "")
View Source
var OK = &Response{
	header:     http.Header{},
	returnCode: ReturnCodeSuccess,
	success:    true,
}

Functions

func Serve

func Serve(addr string, router *Router)

Types

type Error

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

func Abort

func Abort(statusCode int, returnCode string, errorMessage string) *Error

func (*Error) Header

func (r *Error) Header() http.Header

type Parameter

type Parameter struct {
	Parameter *http.Request
	Context   *context
	// contains filtered or unexported fields
}

func (*Parameter) Get

func (argv *Parameter) Get(key string) string

func (*Parameter) GetBool

func (argv *Parameter) GetBool(key string) bool

func (*Parameter) GetInt64

func (argv *Parameter) GetInt64(key string) int64

func (*Parameter) GetInt64Array

func (argv *Parameter) GetInt64Array(key string) []int64

func (*Parameter) GetStringArray

func (argv *Parameter) GetStringArray(key string) []string

func (*Parameter) Unmarshal

func (argv *Parameter) Unmarshal(dest interface{}) error

type RequestFilterFunc

type RequestFilterFunc func(argv *Parameter) *Error

type RequestHandlerFunc

type RequestHandlerFunc func(*Parameter) *Response

type RequestStatinfo

type RequestStatinfo struct {
	StartTime     int64
	EndTime       int64
	TotalTimes    int64
	TotalTimecost int64 // 耗时总数,毫秒
	ReturnCodeMap map[string]int64
	// contains filtered or unexported fields
}

func (*RequestStatinfo) Stat

func (stat *RequestStatinfo) Stat(timecost int64, returnCode string)

type Response

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

func Failure

func Failure(returnCode string, errorMessage string) *Response

func Success

func Success(data interface{}) *Response

func (*Response) Header

func (r *Response) Header() http.Header

type Router

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

func NewRouter

func NewRouter() *Router

func (*Router) Connect

func (router *Router) Connect(path string, fn RequestHandlerFunc)

func (*Router) Delete

func (router *Router) Delete(path string, fn RequestHandlerFunc)

func (*Router) Get

func (router *Router) Get(path string, fn RequestHandlerFunc)

func (*Router) GetAllPath

func (router *Router) GetAllPath() []string

func (*Router) Head

func (router *Router) Head(path string, fn RequestHandlerFunc)

func (*Router) NewGroup

func (router *Router) NewGroup(filterArray ...RequestFilterFunc) *Router

func (*Router) Options

func (router *Router) Options(path string, fn RequestHandlerFunc)

func (*Router) Patch

func (router *Router) Patch(path string, fn RequestHandlerFunc)

func (*Router) Post

func (router *Router) Post(path string, fn RequestHandlerFunc)

func (*Router) Put

func (router *Router) Put(path string, fn RequestHandlerFunc)

func (*Router) ServeHTTP

func (router *Router) ServeHTTP(responseWriter http.ResponseWriter, req *http.Request)

func (*Router) SetStatinfoReporter

func (router *Router) SetStatinfoReporter(reportFunc StatinfoReportFunc, reportFrequency int)

func (*Router) Trace

func (router *Router) Trace(path string, fn RequestHandlerFunc)

type StatinfoReportFunc

type StatinfoReportFunc func(*RequestStatinfo)

Jump to

Keyboard shortcuts

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