http

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 15 Imported by: 1

Documentation

Overview

Package http provides opinionated production-ready HTTP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(server *http.Server, opts ...Option) func(context.Context) error

Run wraps start/stop of the HTTP/1 and HTTP/2 clear text server in a single run function with listening on multiple tcp and unix socket address.

It also resister built-in interceptors, e.g recovery, log buffering, and timeout.

Types

type Option

type Option func(*options)

Option configures the http server.

func WithAddress

func WithAddress(addresses ...string) Option

WithAddress provides the address listened by the HTTP server. It should be either tcp address like `:8080` or unix socket address like `unix:nilgo.sock`.

By default, it listens on `localhost:8080` or `:${PORT}` if the environment variable exists.

func WithConfigService

func WithConfigService(configs ...*konf.Config) Option

WithConfigService registers the endpoint `_config/{path}` for config explanation.

It uses the global konf.Config if the configs are not provided.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout provides the duration that timeout http request.

By default, it has 10 seconds timeout.

Directories

Path Synopsis
Package client provides opinionated production-ready HTTP client.
Package client provides opinionated production-ready HTTP client.

Jump to

Keyboard shortcuts

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