Documentation ¶
Overview ¶
Package httpsrv implements HTTP server that uses JSON payloads for data communication.
See OpenAPI specification at https://github.com/nmezhenskyi/rcs/blob/main/api/openapi/rcs.yaml.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct { Logger zerolog.Logger // By defaut Logger is disabled, but can be manually attached. // contains filtered or unexported fields }
Server implements RCS HTTP API according to specification.
func NewServer ¶
NewServer initializes a new Server instance ready to be used and returns a pointer to it. A zerolog.Logger can be attached to returned Server by accessing public field Server.Logger.
func (*Server) Close ¶
Close immediately closes all active connections and underlying listener. For a graceful shutdown, use Shutdown. Once Close has been called on a server, it may not be reused.
Close returns any error returned from closing the Server's underlying listener.
func (*Server) ListenAndServe ¶
ListenAndServe listens on the given TCP network address addr and handles requests on incoming connections according to RCS HTTP API specification.
Unlike http.Server, it does not return ErrServerClosed after Shutdown or Close.
func (*Server) ListenAndServeTLS ¶
ListenAndServeTLS listens on the given TCP network address addr and handles requests on incoming TLS connections according to RCS HTTP API specification.
Unlike http.Server, it does not return ErrServerClosed after Shutdown or Close.
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP makes the server implement the http.Handler interface.
func (*Server) Shutdown ¶
Shutdown gracefully shuts down the server without interrupting any active connections. Waits until all connections are closed or until context timeout runs out. Once Shutdown has been called on a server, it may not be reused.
Shutdown returns an error returned from closing the Server's underlying listener or a context error.