server

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package server provides a preconfigured HTTP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMuxRouter

func NewMuxRouter() *mux.Router

NewMuxRouter initializes a gorilla/mux router and adds the /api subroute to it

Types

type Driver

type Driver struct {
	Server http.Server
}

Driver implements the driver.Server interface. The zero value is a valid http.Server.

func NewDriver

func NewDriver() *Driver

NewDriver creates a Driver enfolding a http.Server with default timeouts.

func (*Driver) ListenAndServe

func (d *Driver) ListenAndServe(addr string, h http.Handler) error

ListenAndServe sets the address and handler on Driver's http.Server, then calls ListenAndServe on it.

func (*Driver) Shutdown

func (d *Driver) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server without interrupting any active connections, by calling Shutdown on Driver's http.Server

type Server

type Server struct {
	Driver driver.Server

	// all logging is done with a zerolog.Logger
	Logger zerolog.Logger

	// Addr optionally specifies the TCP address for the server to listen on,
	// in the form "host:port". If empty, ":http" (port 80) is used.
	// The service names are defined in RFC 6335 and assigned by IANA.
	// See net.Dial for details of the address format.
	Addr string

	// Services used by the various HTTP routes and middleware.
	Services
	// contains filtered or unexported fields
}

Server represents an HTTP server.

func New

func New(rtr *mux.Router, serverDriver driver.Server, lgr zerolog.Logger) *Server

New initializes a new Server and registers routes to the given router

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe is a wrapper to use wherever http.ListenAndServe is used.

func (*Server) Shutdown

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

Shutdown gracefully shuts down the server without interrupting any active connections.

type Services

type Services struct {
	OrgServicer            diygoapi.OrgServicer
	AppServicer            diygoapi.AppServicer
	RegisterUserService    diygoapi.RegisterUserServicer
	PingService            diygoapi.PingServicer
	LoggerService          diygoapi.LoggerServicer
	GenesisServicer        diygoapi.GenesisServicer
	AuthenticationServicer diygoapi.AuthenticationServicer
	AuthorizationServicer  diygoapi.AuthorizationServicer
	PermissionServicer     diygoapi.PermissionServicer
	RoleServicer           diygoapi.RoleServicer
	MovieServicer          diygoapi.MovieServicer
}

Services are used by the application service handlers

Directories

Path Synopsis
Package driver defines an interface for custom HTTP listeners.
Package driver defines an interface for custom HTTP listeners.

Jump to

Keyboard shortcuts

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