Documentation ¶
Index ¶
- Constants
- func DumpRequestOut(req *http.Request)
- func DumpResponse(resp *http.Response)
- func GetRouter() http.Handler
- func NewGZipBodyReader(body io.ReadCloser) (io.ReadCloser, error)
- func RegisterServant(servant interface{})
- type ROAServantService
- type ROAServerHandler
- type Route
- type Server
- func (srv *Server) AcceptOne()
- func (srv *Server) CloseOne() bool
- func (srv *Server) File() *os.File
- func (srv *Server) Listen() error
- func (srv *Server) ListenAndServe() (err error)
- func (srv *Server) ListenAndServeTLS(certFile, keyFile string) (err error)
- func (srv *Server) ListenTLS() error
- func (srv *Server) RegisterListener(l net.Listener)
- func (srv *Server) Serve() (err error)
- func (srv *Server) Shutdown()
- type ServerConfig
- type TCPListener
- type URLClient
- type URLClientOption
- type URLPattern
Constants ¶
View Source
const ( HTTPMethodGet = http.MethodGet HTTPMethodPut = http.MethodPut HTTPMethodPost = http.MethodPost HTTPMethodDelete = http.MethodDelete CtxResponse = "_server_response" CtxRequest = "_server_request" CtxMatchPattern = "_server_match_pattern" CtxMatchFunc = "_server_match_func" CtxResponseObject = "_server_response_object" ServerChainName = "_server_chain" HeaderResponseStatus = "X-Response-Status" HeaderAllow = "Allow" HeaderHost = "Host" HeaderServer = "Server" HeaderContentType = "Content-Type" HeaderContentEncoding = "Content-Encoding" HeaderAccept = "Accept" HeaderAcceptEncoding = "Accept-Encoding" AcceptAny = "*/*" ContentTypeJSON = "application/json; charset=UTF-8" ContentTypeText = "text/plain; charset=UTF-8" DefaultConnPoolPerHostSize = 5 )
Variables ¶
This section is empty.
Functions ¶
func DumpRequestOut ¶
func DumpResponse ¶
func NewGZipBodyReader ¶
func NewGZipBodyReader(body io.ReadCloser) (io.ReadCloser, error)
func RegisterServant ¶
func RegisterServant(servant interface{})
RegisterServant registers a ROAServantService into serverHandler servant must be an pointer to service object
Types ¶
type ROAServantService ¶
type ROAServantService interface {
URLPatterns() []Route
}
ROAServantService defines a group of Routes
type ROAServerHandler ¶
type ROAServerHandler struct {
// contains filtered or unexported fields
}
ROAServerHandler is a HTTP request multiplexer Attention:
- not thread-safe, must be initialized completely before serve http request
- redirect not supported
func NewROAServerHander ¶
func NewROAServerHander() *ROAServerHandler
NewROAServerHander news an ROAServerHandler
func (*ROAServerHandler) RegisterServant ¶
func (roa *ROAServerHandler) RegisterServant(servant interface{})
RegisterServant registers a ROAServantService servant must be an pointer to service object
func (*ROAServerHandler) ServeHTTP ¶
func (roa *ROAServerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler
type Route ¶
type Route struct { // Method is one of the following: GET,PUT,POST,DELETE Method string // Path contains a path pattern Path string // rest callback function for the specified Method and Path Func func(w http.ResponseWriter, r *http.Request) }
Route is a http route
type Server ¶
type Server struct { *http.Server Network string KeepaliveTimeout time.Duration GraceTimeout time.Duration Listener net.Listener // contains filtered or unexported fields }
func NewServer ¶
func NewServer(srvCfg *ServerConfig) *Server
func (*Server) ListenAndServe ¶
func (*Server) ListenAndServeTLS ¶
func (*Server) RegisterListener ¶
RegisterListener register the instance created outside by net.Listen() in server
type ServerConfig ¶
type ServerConfig struct { Addr string Handler http.Handler ReadTimeout time.Duration ReadHeaderTimeout time.Duration IdleTimeout time.Duration WriteTimeout time.Duration KeepAliveTimeout time.Duration GraceTimeout time.Duration MaxHeaderBytes int TLSConfig *tls.Config Compressed bool CompressMinBytes int }
func DefaultServerConfig ¶
func DefaultServerConfig() *ServerConfig
type TCPListener ¶
func NewTCPListener ¶
func NewTCPListener(l net.Listener, srv *Server) (el *TCPListener)
func (*TCPListener) Close ¶
func (rl *TCPListener) Close() error
func (*TCPListener) File ¶
func (rl *TCPListener) File() *os.File
type URLClient ¶
type URLClient struct { *http.Client TLS *tls.Config Cfg URLClientOption }
func GetURLClient ¶
func GetURLClient(o URLClientOption) (client *URLClient, err error)
type URLClientOption ¶
type URLClientOption struct { SSLEnabled bool Compressed bool VerifyPeer bool CAFile string CertFile string CertKeyFile string CertKeyPWD string SSLVersion uint16 HandshakeTimeout time.Duration ResponseHeaderTimeout time.Duration RequestTimeout time.Duration ConnsPerHost int }
func DefaultURLClientOption ¶
func DefaultURLClientOption() URLClientOption
type URLPattern ¶
URLPattern defines an uri pattern
Source Files ¶
Click to show internal directories.
Click to hide internal directories.