http

package
v0.0.0-...-d1a2b61 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAddr = ":3456"

DefaultAddr is the default bind address.

Variables

This section is empty.

Functions

func Error

func Error(ctx context.Context, w http.ResponseWriter, err error, code int)

Error writes an API error message to the response and logger.

Types

type Server

type Server struct {
	Handler http.Handler

	// Handlers to serve by map
	Routing map[string]http.Handler

	// Bind address to open.
	Addr string
	// contains filtered or unexported fields
}

Server represents an HTTP server.

func NewServer

func NewServer() *Server

NewServer returns a new instance of Server.

func (*Server) AddHandler

func (s *Server) AddHandler(h http.Handler, path string) error

func (*Server) Close

func (s *Server) Close() error

Close closes the socket.

func (*Server) Handlers

func (s *Server) Handlers() http.Handler

func (*Server) Open

func (s *Server) Open() error

Open opens a socket and serves the HTTP server.

func (*Server) Port

func (s *Server) Port() int

Port returns the port that the server is open on. Only valid after open.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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