handler

package
v0.0.0-...-ef924d7 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package handler contains the main logic to accept external requests.

I defines interfaces shared by other packages that accept external requests. Packages that implement these interfaces include:

  • handler/http

It also manages the lifecycle of those handlers. All handlers should be registered to this package in order to be gracefuly stopped (drained) when the application shuts down.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyReg = errors.New("there must be at least one registered handler")

ErrEmptyReg is the error returned when there are no handlers registered

Functions

This section is empty.

Types

type H

type H interface {
	Serve(addr string, ctx app.Ctx) error
	Drain()
}

H is the interface to implement to be a valid handler

type Reg

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

Reg (registry) holds a list of H

func NewReg

func NewReg(ctx app.Ctx) *Reg

NewReg builds a new registry

func (*Reg) Add

func (r *Reg) Add(addr string, h H)

Add adds the given handler to the list of handlers

func (*Reg) Drain

func (r *Reg) Drain()

Drain notify all handlers to enter in draining mode. It means they are no longer accepting new requests, but they can finish all in-flight requests

func (*Reg) Serve

func (r *Reg) Serve() error

Serve allows handlers to serve requests

Directories

Path Synopsis
Package http is an extra layer on to of the standard go net/http package.
Package http is an extra layer on to of the standard go net/http package.

Jump to

Keyboard shortcuts

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