httpsrv

package
v0.6.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2022 License: MIT Imports: 9 Imported by: 0

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

func NewServer(c *cache.CacheMap) *Server

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

func (s *Server) Close() error

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

func (s *Server) ListenAndServe(addr string) error

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

func (s *Server) ListenAndServeTLS(addr, certFile, keyFile string) error

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

func (s *Server) Shutdown(ctx context.Context) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL