Documentation
¶
Index ¶
- Constants
- type Config
- type Logger
- type Route
- type Server
- func (s *Server) ListenAndServe() error
- func (s *Server) RespondWithError(ctx context.Context, w http.ResponseWriter, r *http.Request, httpStatus int, ...)
- func (s *Server) RespondWithJSON(ctx context.Context, w http.ResponseWriter, httpStatus int, body interface{})
- func (s *Server) RespondWithMessage(ctx context.Context, w http.ResponseWriter, httpStatus int, msg string)
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) Shutdown(ctx context.Context) error
- type Storage
Constants ¶
View Source
const ( WS1000001 = "WS-1000001" WS1000002 = "WS-1000002" WS1000003 = "WS-1000003" WS1000004 = "WS-1000004" WS1000005 = "WS-1000005" WS1000006 = "WS-1000006" WS1000007 = "WS-1000007" WS1000008 = "WS-1000008" WS1000009 = "WS-1000009" WS1000010 = "WS-1000010" )
All error codes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Port int `json:"port" envvar:"PORT,required"` ReadTimeout time.Duration `json:"readTimeout" envvar:"READ_TIMEOUT,default=3s"` WriteTimeout time.Duration `json:"writeTimeout" envvar:"WRITE_TIMEOUT,default=3s"` Logger Logger `json:"-" envvar:"-"` IncludeStatusCodeInMessages bool `json:"-" envvar:"-"` Storage Storage `json:"-" envvar:"-"` }
Config contains information necessary to set up a Server.
func (*Config) CfgBuildInit ¶
CfgBuildInit initializes the Logger. It should only be called by a cfgbuild.Builder.
func (*Config) CfgBuildValidate ¶
CfgBuildValidate checks the specified values. It should only be called by a cfgbuild.Builder.
type Route ¶
type Route struct { Name string Method string Pattern string HandlerFunc http.HandlerFunc }
A Route describes a rest endpoint.
type Server ¶
A Server is a web server that extends http.Server. It should be created with the New() function, started with the Server.ListenAndServe() function, and can be cleanly closed with the Server.Shutdown() function.
func (*Server) ListenAndServe ¶
func (*Server) RespondWithError ¶
func (*Server) RespondWithJSON ¶
func (*Server) RespondWithMessage ¶
Click to show internal directories.
Click to hide internal directories.