server

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HttpError

func HttpError(wr http.ResponseWriter, status int, info string, showtrace bool)

Types

type HttpConfig

type HttpConfig struct {
	ReadTimeout       time.Duration
	ReadHeaderTimeout time.Duration
	WriteTimeout      time.Duration
	IdleTimeout       time.Duration
}

type RequestHandler

type RequestHandler func(ctx *common.RequestCtx) interface{}

type RequestMapping

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

type RequestMethod

type RequestMethod string
const (
	Get     RequestMethod = "GET"
	Post    RequestMethod = "POST"
	Put     RequestMethod = "PUT"
	Delete  RequestMethod = "DELETE"
	Head    RequestMethod = "HEAD"
	Options RequestMethod = "OPTIONS"
)

type ResponseWrapper

type ResponseWrapper interface {
	Wrap(v interface{}, wr http.ResponseWriter) bool
}

customize response by handle it manually return true if handled

type RestController

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

func (*RestController) ServeHTTP

func (c *RestController) ServeHTTP(wr http.ResponseWriter, r *http.Request)

type RestServer

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

func NewRestServer

func NewRestServer(address string, config *HttpConfig) *RestServer

func (*RestServer) AddInterceptor

func (s *RestServer) AddInterceptor(interceptor midware.Interceptor)

func (*RestServer) AddResponseWrapper

func (s *RestServer) AddResponseWrapper(wrapper ResponseWrapper)

append to the top of response

func (*RestServer) DELETE

func (s *RestServer) DELETE(pattern string, handler RequestHandler) *RestServer

func (*RestServer) GET

func (s *RestServer) GET(pattern string, handler RequestHandler) *RestServer

func (*RestServer) Mapping

func (s *RestServer) Mapping(method RequestMethod, pattern string, handler RequestHandler) *RestServer

func (*RestServer) POST

func (s *RestServer) POST(pattern string, handler RequestHandler) *RestServer

func (*RestServer) PUT

func (s *RestServer) PUT(pattern string, handler RequestHandler) *RestServer

func (*RestServer) StartServer

func (s *RestServer) StartServer()

func (*RestServer) StartServerAsync

func (s *RestServer) StartServerAsync() *http.Server

func (*RestServer) WithSQL

func (c *RestServer) WithSQL(sql *sql.SQL)

Jump to

Keyboard shortcuts

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