httputil

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Provides HTTP server implementation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	*gin.Engine
	// contains filtered or unexported fields
}

Server is an object representing gin.Engine and implementing the lifecycle.Service interface.

func NewServer

func NewServer(c *config.Config, opts ...ServerOpt) *Server

NewServer create new Server using global configuration and provided options. Function reads "http.address" config key to determine an address for HTTP listener (by default: 0.0.0.0:8080). Other config keys are "http.security.headers" which controls whether server should automatically include HTTP security headers to its responses and "http.shutdown.timeout" which defines a maximum time of shutdown in seconds.

func (*Server) Start

func (server *Server) Start() error

Start implements the interface of lifecycle.Service

func (*Server) Stop

func (server *Server) Stop()

Stop implements the interface of lifecycle.Service

type ServerOpt

type ServerOpt = func(*serverConfig)

ServerOpt is an option to be specified to NewServer.

func SecurityHeaders

func SecurityHeaders(securityHeaders bool) ServerOpt

SecurityHeaders defines whether to include HTTP security headers to all responses or not

func ShutdownTimeout

func ShutdownTimeout(seconds int64) ServerOpt

ShutdownTimeout defines a maximal timeout of HTTP server shutdown

Jump to

Keyboard shortcuts

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