server

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package server implements the replicant server API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ListenAddress     string        `json:"listen_address" yaml:"listen_address"`
	WriteTimeout      time.Duration `json:"write_timeout" yaml:"write_timeout"`
	ReadTimeout       time.Duration `json:"read_timeout" yaml:"read_timeout"`
	ReadHeaderTimeout time.Duration `json:"read_header_timeout" yaml:"read_header_timeout"`
}

Config for replicant server

type Handler

type Handler = httprouter.Handle

Handler is a http handler

type Params

type Params = httprouter.Params

Params from the URL

type SHandler added in v0.1.15

type SHandler func(*Server) Handler

SHandler is handler that has access to the server

type Server

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

Server is an replicant manager and api server

func New

func New(config Config, m *manager.Manager, r *httprouter.Router) (server *Server, err error)

New creates a new replicant server

func (*Server) AddHandler

func (s *Server) AddHandler(method, path string, handler Handler)

AddHandler adds a handler for the given method and path

func (*Server) AddServerHandler

func (s *Server) AddServerHandler(method, path string, handler SHandler)

AddServerHandler adds a handler for the given method and path

func (*Server) Close

func (s *Server) Close(ctx context.Context) (err error)

Close this server

func (*Server) Manager

func (s *Server) Manager() (m *manager.Manager)

Manager returns this server replicant manager

func (*Server) Router

func (s *Server) Router() (r *httprouter.Router)

Router returns this server http router

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements the http.Handler interface for testing and handler usage

func (*Server) Start

func (s *Server) Start() (err error)

Start serving

Jump to

Keyboard shortcuts

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