http

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package http provides HTTP client and server implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options added in v0.7.0

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

	// Cert and Key are required for enabling TLS.
	Cert, Key string

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

	ShutdownCtx func() context.Context
}

Options wraps all the customizable options for a Server.

type Server

type Server struct {
	http.Server

	// TLS certificates.
	Cert, Key string

	// 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
	// contains filtered or unexported fields
}

Server is a http.Server with some extra functionalities.

func NewServer

func NewServer(opts Options) *Server

NewServer creates a new Server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() (err error)

ListenAndServe listens for HTTP requests. If s.Addr is a filepath, the server will listen in a Unix Domain Socket; if s.Cert and s.Key are not empty, the server will listen over a TLS listener; otherwise the server will listen on a regular TCP listener.

By default, the server will gracefully shutdown when the program receives a SIGINT signal.

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