Documentation
¶
Overview ¶
Package http provides http client and server implementations.
Package http provides http client and server implementations.
Index ¶
- type Response
- type Server
- func (this *Server) RegisterHandler(path string, handler http.Handler, methods ...string)
- func (this *Server) RegisterHandlerFunc(path string, handlerFunc http.HandlerFunc, methods ...string)
- func (this *Server) RegisterPathPrefixHandler(prefix string, handler http.Handler, methods ...string)
- func (this *Server) RegisterPathPrefixHandlerFunc(prefix string, handlerFunc http.HandlerFunc, methods ...string)
- func (this *Server) SetRouter(router *mux.Router)
- func (this *Server) Start(address string, listenAndServeFailureFunc func(err error), ...) error
- func (this *Server) Stop(shutdownTimeout time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Response ¶
Response is response information.
func Request ¶
func Request(url, method string, header map[string][]string, body string, timeout time.Duration, username, password string, transport *http.Transport) (Response, error)
Request is request.
ex) response, err := http.Request("http://127.0.0.1:10000/test/id-01", http.MethodGet, map[string][]string{"header-1": {"value-1"}}, "", 10, "", "", nil)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a struct that provides server related methods.
func (*Server) RegisterHandler ¶ added in v1.1.8
RegisterHandler is add handler.
ex)
server.RegisterHandler("/xxx", handler) //all method
server.RegisterHandler("/xxx", handler, http.MethodGet)
server.RegisterHandler("/xxx", handler, http.MethodGet, http.MethodPost)
func (*Server) RegisterHandlerFunc ¶ added in v1.1.6
func (this *Server) RegisterHandlerFunc(path string, handlerFunc http.HandlerFunc, methods ...string)
RegisterHandlerFunc is add handler function.
ex)
server.RegisterHandlerFunc("/xxx", handlerFunc) //all method
server.RegisterHandlerFunc("/xxx", handlerFunc, http.MethodGet)
server.RegisterHandlerFunc("/xxx", handlerFunc, http.MethodGet, http.MethodPost)
func (*Server) RegisterPathPrefixHandler ¶ added in v1.1.6
func (this *Server) RegisterPathPrefixHandler(prefix string, handler http.Handler, methods ...string)
RegisterPathPrefixHandler is add path prefix handler.
ex)
server.RegisterPathPrefixHandler("/xxx", handler) //all method
server.RegisterPathPrefixHandler("/xxx", handler, http.MethodGet)
server.RegisterPathPrefixHandler("/xxx", handler, http.MethodGet, http.MethodPost)
func (*Server) RegisterPathPrefixHandlerFunc ¶ added in v1.1.8
func (this *Server) RegisterPathPrefixHandlerFunc(prefix string, handlerFunc http.HandlerFunc, methods ...string)
RegisterPathPrefixHandlerFunc is add path prefix handler function.
ex)
server.RegisterPathPrefixHandlerFunc("/xxx", handlerFunc) //all method
server.RegisterPathPrefixHandlerFunc("/xxx", handlerFunc, http.MethodGet)
server.RegisterPathPrefixHandlerFunc("/xxx", handlerFunc, http.MethodGet, http.MethodPost)
Click to show internal directories.
Click to hide internal directories.