fxhttp

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2018 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

Example
package main

import (
	"net/http"

	"github.com/goph/fxt"
	fxhttp "github.com/goph/fxt/http"
	"go.uber.org/fx"
)

func main() {
	app := fx.New(
		fx.NopLogger,
		fxt.Bootstrap,
		fx.Provide(
			func() *fxhttp.Config {
				return fxhttp.NewConfig(":8080")
			},
			func() http.Handler {
				return http.NewServeMux()
			},
			fxhttp.NewServer,
		),
	)

	if err := app.Err(); err != nil {
		panic(err)
	}

}
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrServerClosed = http.ErrServerClosed

ErrServerClosed is returned by the underlying server when it stops listening after graceful or forceful shutdown is initiated.

Functions

This section is empty.

Types

type Config

type Config struct {
	Network string
	Addr    string
}

Config holds a list of options used during the http server construction.

func NewConfig

func NewConfig(addr string) *Config

NewConfig returns a new config populated with default values.

type Err

type Err <-chan error

Err accepts an error which causes the application to stop.

func NewServer

func NewServer(params ServerParams) Err

NewServer creates a new http server.

type ServerParams

type ServerParams struct {
	dig.In

	Config          *Config
	Handler         http.Handler
	Logger          log.Logger        `optional:"true"`
	HealthCollector healthz.Collector `optional:"true"`
	Lifecycle       fxt.Lifecycle
}

ServerParams provides a set of dependencies for a http server constructor.

Directories

Path Synopsis
gorilla
mux
middleware

Jump to

Keyboard shortcuts

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