http

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package http provides HTTP server implementation based on http package from the stdlib.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// TCP address to listen on. If a file path is given, the server will use a
	// Unix Domain Socket.
	Addr string

	// Requests handler. Just as http.Server, if nil is given,
	// http.DefaultServeMux will be used.
	Handler http.Handler

	ShutdownCtx func() context.Context
}

Config wraps all the customizable options from Server.

type Server

type Server struct {
	http.Server

	// Shutdown context used for gracefully shutdown, it is implemented as a
	// function since deadlines will start at server creation and not at shutdown.
	ShutdownCtx func() context.Context

	// Gracefully shutdown done notifier.
	Done chan struct{}
}

Server is a http.Server with some extra functionalities.

func NewServer

func NewServer(c *Config) *Server

NewServer creates and setups a new Server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe listen in a TCP address for HTTP requests.

func (*Server) ListenAndServeTLS

func (s *Server) ListenAndServeTLS(cert, key string) error

ListenAndServeTLS listen in a TCP address for HTTPS/H2 requests.

func (*Server) ListenAndServeUDS

func (s *Server) ListenAndServeUDS() error

ListenAndServeUDS listen in a Unix Domain Socket for HTTPS/H2 requests.

func (*Server) Setup

func (s *Server) Setup(c *Config)

Setup prepares the Server with the given Config.

Directories

Path Synopsis
Package middleware provides flexibility at the HTTP request/response process.
Package middleware provides flexibility at the HTTP request/response process.

Jump to

Keyboard shortcuts

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