Documentation ¶
Index ¶
- Variables
- func FetchUID(r *http.Request) (string, error)
- func HealthHandler(w http.ResponseWriter, _ *http.Request)
- func WriteCORSHeaders(w http.ResponseWriter, r *http.Request, origins []string)
- type Config
- type DefaultHeadersExtractor
- type HTTPServer
- func (s *HTTPServer) Address() string
- func (s *HTTPServer) Running() bool
- func (s *HTTPServer) SetupHandler(path string, handler http.Handler)
- func (s *HTTPServer) Shutdown(ctx context.Context) error
- func (s *HTTPServer) ShutdownCtx() context.Context
- func (s *HTTPServer) Start() error
- func (s *HTTPServer) StartAndAnnounce(name string) error
- func (s *HTTPServer) Stopped() bool
- type HeadersExtractor
- type RequestInfo
- type SSLConfig
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func FetchUID ¶ added in v1.4.0
FetchUID safely extracts uid from `X-Request-ID` header or generates a new one
func HealthHandler ¶ added in v1.0.1
func HealthHandler(w http.ResponseWriter, _ *http.Request)
HealthHandler always reponds with 200 status
func WriteCORSHeaders ¶ added in v1.4.4
func WriteCORSHeaders(w http.ResponseWriter, r *http.Request, origins []string)
Types ¶
type Config ¶ added in v1.5.4
type DefaultHeadersExtractor ¶ added in v1.4.0
func (*DefaultHeadersExtractor) FromRequest ¶ added in v1.4.0
func (h *DefaultHeadersExtractor) FromRequest(r *http.Request) map[string]string
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer is wrapper over http.Server
func ForPort ¶ added in v1.0.1
func ForPort(port string) (*HTTPServer, error)
ForPort creates new or returns the existing server for the specified port
func (*HTTPServer) Address ¶
func (s *HTTPServer) Address() string
Address returns server scheme://host:port
func (*HTTPServer) Running ¶ added in v1.0.1
func (s *HTTPServer) Running() bool
Running returns true if server has been started
func (*HTTPServer) SetupHandler ¶ added in v1.3.0
func (s *HTTPServer) SetupHandler(path string, handler http.Handler)
SetupHandler adds new handler to mux
func (*HTTPServer) Shutdown ¶ added in v1.1.0
func (s *HTTPServer) Shutdown(ctx context.Context) error
Shutdown shuts down server gracefully.
func (*HTTPServer) ShutdownCtx ¶ added in v1.4.4
func (s *HTTPServer) ShutdownCtx() context.Context
ShutdownCtx returns context for graceful shutdown. It must be used by HTTP handlers to termniates long-running requests (SSE, long-polling).
func (*HTTPServer) StartAndAnnounce ¶ added in v1.0.1
func (s *HTTPServer) StartAndAnnounce(name string) error
StartAndAnnounce prints server info and starts server
func (*HTTPServer) Stopped ¶
func (s *HTTPServer) Stopped() bool
Stopped return true iff server has been stopped by user
type HeadersExtractor ¶ added in v1.4.0
type RequestInfo ¶ added in v1.4.0
type RequestInfo struct { UID string URL string Headers *map[string]string // contains filtered or unexported fields }
func NewRequestInfo ¶ added in v1.4.0
func NewRequestInfo(r *http.Request, extractor HeadersExtractor) (*RequestInfo, error)
func (*RequestInfo) AnyCableHeader ¶ added in v1.4.3
func (i *RequestInfo) AnyCableHeader(key string) string
func (*RequestInfo) Param ¶ added in v1.4.3
func (i *RequestInfo) Param(key string) string
type SSLConfig ¶ added in v1.0.1
SSLConfig contains SSL parameters
func NewSSLConfig ¶ added in v1.0.1
func NewSSLConfig() SSLConfig
NewSSLConfig build a new SSLConfig struct