Versions in this module Expand all Collapse all v0 v0.21.1 Apr 1, 2019 Changes in this version + const ErrCodeAccessDenied + const ErrCodeFailedToParseRequest + const ErrCodeInternalServerError + const ErrCodeMax + const ErrCodeMethodNotAllowed + var ErrAccessDenied = &Error + var ErrFailedToParseRequest = &Error + var ErrInternalServerError = &Error + var ErrMethodNotAllowed = &Error + func GetURL(conf *Config, path string) string + func NewHTTPRequest(conf *Config, method, path string, req *Request) (*http.Request, error) + func NewHTTPRequestWithURL(method, url string, req *Request) (*http.Request, error) + type AuthFunc func(username, password string) bool + type Config struct + Addr string + TLS *TLSConfig + func NewConfig() *Config + type Context struct + Username string + type Error struct + Code int + Message string + Status int + func (e *Error) Error() string + type HandlerFunc func(w http.ResponseWriter, r *http.Request, ctx *Context) + type Request struct + Args json.RawMessage + type Response struct + Error *Error + Result json.RawMessage + func Send(req *http.Request) (*Response, error) + type Server struct + func NewServer(conf *Config) *Server + func (s *Server) Close() error + func (s *Server) HandleFunc(pattern string, handler HandlerFunc) + func (s *Server) ListenAndServe() error + func (s *Server) Mux() *http.ServeMux + func (s *Server) ParseRequest(logger log.Logger, w http.ResponseWriter, r *http.Request, args interface{}) bool + func (s *Server) RequireBasicAuth(logger log.Logger, handler HandlerFunc, auth AuthFunc) HandlerFunc + func (s *Server) RequireHTTPMethods(logger log.Logger, handler HandlerFunc, methods ...string) HandlerFunc + func (s *Server) RespondError(logger log.Logger, w http.ResponseWriter, err *Error) + func (s *Server) RespondResult(logger log.Logger, w http.ResponseWriter, result interface{}) + type TLSConfig struct + CertFile string + KeyFile string