http

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: BSD-3-Clause Imports: 8 Imported by: 1

Documentation

Overview

Package http provides an HTTP server with a configurable server and router.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Server)

Option is a function to configure a Server.

func WithOptions

func WithOptions(opts ...Option) Option

WithOptions construct an Option that applies multiple Option to a Server.

func WithRoute

func WithRoute(method, path string, handler http.Handler) Option

WithRoute construct an Option that adds a route to the Server's router.

func WithRouterOption

func WithRouterOption(opt func(*mux.Router)) Option

WithRouterOption construct an Option that configure the Server's router.

func WithServerOption

func WithServerOption(opt func(*http.Server)) Option

WithServerOption construct an Option that configure the Server's http.Server.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server carries an HTTP server and a router that can be configured through Option when instantiating it.

func NewServer

func NewServer(addr string, opts ...Option) *Server

NewServer creates a new HTTP Server with the given listening address and configured with the provided Option.

func (*Server) Listen

func (s *Server) Listen() error

Listen runs the server in a blocking way. In returns either if an error occur which in that case returns the error, or if the server is stopped by a signal (i.e. `SIGINT` or `SIGTERM`).

Jump to

Keyboard shortcuts

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