Documentation
¶
Index ¶
- Constants
- type CallCounter
- 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
Constants ¶
View Source
const ( MAAS1000001 = "MAAS-1000001" MAAS1000002 = "MAAS-1000002" MAAS1000003 = "MAAS-1000003" MAAS1000004 = "MAAS-1000004" MAAS1000005 = "MAAS-1000005" MAAS1000006 = "MAAS-1000006" MAAS1000007 = "MAAS-1000007" MAAS1000008 = "MAAS-1000008" MAAS1000009 = "MAAS-1000009" MAAS1000010 = "MAAS-1000010" )
All error codes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallCounter ¶
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:"-"` CallCounter CallCounter `json:"-" envvar:"-"` IncludeStatusCodeInMessages bool `json:"-" envvar:"-"` AstraConfig astra.Config `json:"-" envvar:">,prefix=ASTRA_"` }
Config contains information necessary to set up a Server.
func (*Config) CfgBuildInit ¶
CfgBuildInit initializes the Logger and CallCounter. 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.