serve

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package serve provides helpers to start and shutdown network services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTP

func HTTP(ctx Ctx, addr netx.Addr, tlsConfig *tls.Config, handler http.Handler, service string) error

HTTP starts HTTP server on addr using handler logged as service. It runs until failed or ctx.Done.

func HandleMetrics added in v1.4.0

func HandleMetrics(mux *http.ServeMux, reg *prometheus.Registry)

HandleMetrics adds reg's prometheus handler on /metrics at mux.

func Metrics

func Metrics(ctx Ctx, addr netx.Addr, reg *prometheus.Registry) error

Metrics starts HTTP server on addr path /metrics using reg as prometheus handler.

func OpenAPI

func OpenAPI(ctx Ctx, srv OpenAPIServer, service string) error

OpenAPI starts HTTP/HTTPS server using srv logged as service. It runs until failed or ctx.Done.

Types

type Ctx

type Ctx = context.Context

Ctx is a synonym for convenience.

type OpenAPIServer

type OpenAPIServer interface {
	HTTPListener() (net.Listener, error)
	TLSListener() (net.Listener, error)
	Serve() error
	Shutdown() error
}

OpenAPIServer implemented by *restapi.Server generated by go-swagger.

Jump to

Keyboard shortcuts

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