server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package server implements a web server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAll

func ListenAll(s ...*Server) error

ListenAll invokes listen for the given servers

Types

type Options

type Options struct {
	// ID of the server
	ID string
	// Address of the server
	Address string
	// PathPrefix holds HTTP path prefix
	PathPrefix string
}

Options represents the options than can be set when creating a new server

type Server

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

Server represents a web server

func New

func New(o Options) *Server

New returns a new web server by the given options

func (*Server) AddHandler

func (server *Server) AddHandler(pattern string, handler http.Handler)

AddHandler adds a handler

func (*Server) AddHandlerFunc

func (server *Server) AddHandlerFunc(pattern string, handler func(http.ResponseWriter, *http.Request))

AddHandlerFunc adds a handler function

func (*Server) AddPage

func (server *Server) AddPage(p *page.Page) error

AddPage adds a page

func (*Server) AddPages

func (server *Server) AddPages(p ...*page.Page) error

AddPages adds pages

func (*Server) Address

func (server *Server) Address() string

Address returns the server address

func (*Server) Close

func (server *Server) Close() error

Close closes all active listeners and connections immediately

func (*Server) ID

func (server *Server) ID() string

ID returns the server id

func (*Server) Listen

func (server *Server) Listen() error

Listen initializes the server and listens for requests

func (*Server) PathRoot

func (server *Server) PathRoot() string

PathRoot returns the server path prefix

func (*Server) Routes

func (server *Server) Routes() []route.Route

Routes returns the list of the routes

func (*Server) Shutdown

func (server *Server) Shutdown() error

Shutdown gracefully shuts down the server

Jump to

Keyboard shortcuts

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