web

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package web provides a web server with some standardized logging and handler wrapping.

Index

Constants

View Source
const (
	ProtocolHTTP  = "http"
	ProtocolHTTPS = "https"
)

Constants for protocols the server can provide.

Variables

This section is empty.

Functions

func HasMorePathSegments

func HasMorePathSegments(req *http.Request) bool

HasMorePathSegments returns true if more path segments will be returned from future calls to PathHeadThenShift() for the request.

func LastPathHead

func LastPathHead(req *http.Request) string

LastPathHead returns the last result obtained from a call to PathHeadThenShift() for the request.

func PathHeadThenShift

func PathHeadThenShift(req *http.Request) string

PathHeadThenShift returns the head segment of the request's adjusted path, then shifts it left by one segment. This does not adjust the path stored in req.URL.Path.

func RemainingPath

func RemainingPath(req *http.Request) string

RemainingPath returns the remaining path for a request.

Types

type Server

type Server struct {
	CertFile            string
	KeyFile             string
	ShutdownGracePeriod time.Duration
	Logger              logadapter.Logger
	WebServer           *http.Server
	Ports               []int
	ShutdownCallback    func()
	StartedChan         chan interface{} // If not nil, will be closed once the server is ready to accept connections
	// contains filtered or unexported fields
}

Server holds the data necessary for the server.

func (*Server) Addresses

func (s *Server) Addresses() []string

Addresses returns the host addresses being listened to.

func (*Server) LocalBaseURL

func (s *Server) LocalBaseURL() string

LocalBaseURL returns the local base URL that will reach the server.

func (*Server) Port

func (s *Server) Port() int

Port returns the port being listened to.

func (*Server) Protocol

func (s *Server) Protocol() string

Protocol returns the protocol this server is handling.

func (*Server) Run

func (s *Server) Run() error

Run the server. Does not return until the server is shutdown.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown the server gracefully.

func (*Server) String

func (s *Server) String() string

Jump to

Keyboard shortcuts

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