api

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHandlerFunc

func AddHandlerFunc(api string, h handlerFunc) error

AddHandlerFunc provides interface to add customized handlerFunc

Types

type Config

type Config struct {
	Enabled            bool   `config:"enabled"`
	Host               string `config:"host"`
	Port               int    `config:"port"`
	User               string `config:"named_pipe.user"`
	SecurityDescriptor string `config:"named_pipe.security_descriptor"`
}

Config is the configuration for the API endpoint.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig is the default configuration used by the API endpoint.

type Server

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

Server takes cares of correctly starting the HTTP component of the API and will answers all the routes defined in the received ServeMux.

func New

func New(log *logp.Logger, mux *http.ServeMux, c *config.C) (*Server, error)

New creates a new API Server.

func NewWithDefaultRoutes

func NewWithDefaultRoutes(log *logp.Logger, c *config.C, ns lookupFunc) (*Server, error)

NewWithDefaultRoutes creates a new server with default API routes.

func (*Server) AttachHandler

func (s *Server) AttachHandler(route string, h http.Handler) (err error)

AttachHandler will attach a handler at the specified route and return an error instead of panicing.

func (*Server) AttachPprof

func (s *Server) AttachPprof()

func (*Server) Start

func (s *Server) Start()

Start starts the HTTP server and accepting new connection.

func (*Server) Stop

func (s *Server) Stop() error

Stop stops the API server and free any resource associated with the process like unix sockets.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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