server

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAPIInitializationFailed = errors.New("API failed to initialize")
)

Functions

func API

func API(serverConfig APIServerConfig, badgeConfig badges.BadgeConfig, assetConfig assets.Config, badgeConfigDir string) error

API launches an ApiV1 instance server and manages it's lifecycle.

func APIConfigure

func APIConfigure[T api.ServerInterface](serverConfig APIServerConfig, apiInstance T, apiPrefix string) func(e *echo.Echo) error

APIConfigure implements the logic necessary to launch an API from a server config and a server. The primary difference to API() is that the apInstance interface is explicitly passed.

func EchoSwaggerUIHandler

func EchoSwaggerUIHandler(uiPath string, swaggerUISpec []byte) echo.HandlerFunc

func Index

func Index(c echo.Context) error

func Live

func Live(c echo.Context) error

Live returns 200 OK if the application server is still functional and able to handle requests.

func Ready

func Ready(c echo.Context) error

Ready returns 200 OK if the application is ready to serve new requests.

func Server

func Server(serverConfig APIServerConfig, assetConfig assets.Config, templateGlobals pongo2.Context, configFns ...func(e *echo.Echo) error) error

Server configures and starts an Echo server with standard capabilities, and configuration functions.

func Started

func Started(c echo.Context) error

Started returns 200 OK once the application is started.

func StaticGet

func StaticGet(root fs.FS, mimeType string) echo.HandlerFunc

func StaticHead

func StaticHead(root fs.FS, mimeType string) echo.HandlerFunc

Types

type APIHTTPClientConfig

type APIHTTPClientConfig struct {
	Timeout   time.Duration `help:"Default HTTP request timeout" default:"3s"`
	UserAgent string        `help:"User Agent string to send with requests" default:""`
}

APIHTTPClientConfig configures the outbound HTTP request globals.

type APIServerConfig

type APIServerConfig struct {
	Prefix string `help:"Prefix the API is bing served under, if any"`
	Host   string `help:"Host the API should be served on" default:""`
	Port   int    `help:"Port to serve on" default:"8080"`

	HTTPClient APIHTTPClientConfig `embed:"" prefix:"http"`
}

APIServerConfig configures local hosting parameters of the API server.

type LivenessResponse

type LivenessResponse struct {
	RespondedAt time.Time `json:"responded_at"`
}

LivenessResponse is a common type for responding to K8S style liveness checks.

type ReadinessResponse

type ReadinessResponse struct {
	RespondedAt time.Time `json:"responded_at"`
}

ReadinessResponse is a common type for responding to K8S style readiness checks.

type StartedResponse

type StartedResponse struct {
	RespondedAt time.Time `json:"responded_at"`
}

StartedResonse is a common type for responding to K8S style startup checks.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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