core

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 11 Imported by: 2

Documentation

Overview

Interface definitions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API is the main object to create a web application has the config as attribute and it is basically a wrapper around a mux.Router with helpers method to add endpoints (grouped via BlueprintInterface) also monitor andlogger are attributes

func NewAPI

func NewAPI(cfg APIConfigInterface) *API

NewAPI returns a new API object implementing webiface.APIInterface by default the monitoring and status blueprints are registered and the APITimer and APICount middleware are applied

func (*API) Handler

func (a *API) Handler() http.Handler

Handler returns an http handler created from the main router

func (*API) RegisterBlueprints

func (a *API) RegisterBlueprints(r *chi.Mux, blueprints ...webiface.BlueprintInterface)

UseMiddlewares will register all the blueprints to the passed in router if no router r is passed, then the main one is used

func (*API) Router

func (a *API) Router() *chi.Mux

Router returns the main router

func (*API) UseMiddlewares

func (a *API) UseMiddlewares(r *chi.Mux, mwf ...func(http.Handler) http.Handler)

UseMiddlewares will apply all the middleware functions to the passed in router if no router r is passed, then the main one is used

type APIConfigInterface

type APIConfigInterface interface {
	GetServiceName() string
	GetTracer() trace.Tracer
	GetMonitor() core.MonitorInterface
	GetCORSConfig() config.CORSConfigInterface
	GetLogger() logging.LoggerInterface
}

Jump to

Keyboard shortcuts

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