web

package module
v0.0.0-...-ad5a18d Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: MIT Imports: 7 Imported by: 0

README

web

A minimal, boilerplate HTTP server backed by Chi.

License

MIT

Documentation

Overview

Package web implements a simple, boilerplate HTTP server backed by Chi.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Router

func Router(ctx context.Context, rf middleware.RecovererFunc) *chi.Mux

Router provides a base router with useful middlewares already loaded. Consumers can expand upon this by adding their own routes, etc.

The passed context should contain a *zap.Logger for the logging middleware to be effective.

func Start

func Start(ctx context.Context, opts *Options) error

Start runs an HTTP server on the given addr. The server will shutdown when the given context is done.

Types

type Options

type Options struct {
	// The address to listen on.
	Addr string
	// Name of the service the web server is running under.
	Service string
	// Custom routes.
	Router chi.Router
}

Options is used to configure the underlying HTTP server when passed to Start().

Directories

Path Synopsis
Package middleware implements a variety of useful HTTP middleware.
Package middleware implements a variety of useful HTTP middleware.

Jump to

Keyboard shortcuts

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