app

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func With

func With(ctx context.Context, app *App) context.Context

With adds app to ctx.

func WrapHandler

func WrapHandler(app *App, fn HandlerFunc) echo.HandlerFunc

WrapHandler wraps a handler function into a gin.HandlerFunc.

Types

type App

type App struct {
	Config          *Config
	IDM             *idm.Provider
	Customers       customerdb.Database
	Patients        patientdb.Database
	Comments        commentdb.Database
	VoiceMails      voicemaildb.Database
	MailSync        *mailsync.Manager
	Door            *door.Controller
	Holidays        openinghours.HolidayGetter
	LayoutStore     layouts.Store
	InfoScreenShows infoscreendb.Database
	Cache           cache.Cache
	Trigger         *trigger.Registry
	Tmpl2PDF        *tmpl2pdf.Creator

	RosterdServer string
	// contains filtered or unexported fields
}

App holds dependencies for cis API request handlers.

func From

func From(c echo.Context) (*App, error)

From returns the App associated with c. If there is no context assigned to c the request is terminated with 500 Internal Server error.

func FromContext

func FromContext(ctx context.Context) *App

FromContext returns the App associated with c.

func NewApp

func NewApp(
	cfg *Config,
	customers customerdb.Database,
	patients patientdb.Database,
	comments commentdb.Database,
	voicemail voicemaildb.Database,
	mailsyncManager *mailsync.Manager,
	door *door.Controller,
	holidays openinghours.HolidayGetter,
	layoutStore layouts.Store,
	infoScreens infoscreendb.Database,
	cache cache.Cache,
	triggerRegistry *trigger.Registry,
	pdfCreator *tmpl2pdf.Creator,
	RosterdServer string,
	idmProvider *idm.Provider,
) *App

NewApp context creates a new application context.

func (*App) BasePath

func (app *App) BasePath() string

BasePath returns the base path of the application.

func (*App) BaseURL

func (app *App) BaseURL(c *gin.Context) string

BaseURL returns the base URL if the application as configured in the BaseURL setting. If not configured the Host header of the HTTP request is used.

func (*App) EndpointPath

func (app *App) EndpointPath(relativePath string) string

EndpointPath returns the absolute path to the endpoint.

func (*App) Location

func (app *App) Location() *time.Location

Location returns the location CIS is running at. Deprecated: use Config.Location() instead.

func (*App) MarkReady

func (app *App) MarkReady(ctx context.Context)

MarkReady fires the started event and marks the app as being ready.

func (*App) MaxUploadSize

func (app *App) MaxUploadSize() int64

MaxUploadSize returns the maximum upload size allowed for infoscreen layout file uploads. It parses InfoScreenConfig.MaxUploadSize and fallsback to 1MB in case of an invalid setting.

func (*App) ParseTime

func (app *App) ParseTime(layout string, str string) (time.Time, error)

ParseTime is like time.Parse but makes sure the returned time is put into the configured local timezone.

func (*App) String

func (app *App) String() string

type CORS

type CORS struct {
	AllowAllOrigins        bool
	AllowOrigins           []string
	AllowMethods           []string
	AllowHeaders           []string
	AllowCredentials       bool
	ExposeHeaders          []string
	MaxAge                 string
	AllowWildcard          bool
	AllowBrowserExtensions bool
	AllowWebSockets        bool
}

CORS is a type-alias to cors.Config to avoid additional imports in client packages.

type Config

type Config struct {
	cfgspec.Config           `section:"Global"`
	cfgspec.DatabaseConfig   `section:"Global"`
	cfgspec.InfoScreenConfig `section:"InfoScreen"`
	CORS                     `section:"CORS"`
	// contains filtered or unexported fields
}

Config holds the complete cisd configuration.

func (*Config) Location

func (cfg *Config) Location() *time.Location

type HandlerFunc

type HandlerFunc func(ctx context.Context, app *App, c echo.Context) error

HandlerFunc defines a cis HTTP handler func.

type Router

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

Router wraps a gin router interface to use HandlerFunc instead of gin.HandlerFunc.

func NewRouter

func NewRouter(r *echo.Group, app *App) *Router

NewRouter returns a new application router wrapping r.

func (*Router) DELETE

func (r *Router) DELETE(path string, handler HandlerFunc, middlewares ...echo.MiddlewareFunc)

DELETE is like echo.Group.PATCH.

func (*Router) GET

func (r *Router) GET(path string, handler HandlerFunc, middlewares ...echo.MiddlewareFunc)

GET is like echo.Group.GET.

func (*Router) Group

func (r *Router) Group(path string, handlers ...echo.MiddlewareFunc) *Router

Group returns a new router that groups handlers at path. It works like echo.Group.Group.

func (*Router) OPTIONS

func (r *Router) OPTIONS(path string, handler HandlerFunc, middlewares ...echo.MiddlewareFunc)

OPTIONS is like echo.Group.OPTIONS.

func (*Router) PATCH

func (r *Router) PATCH(path string, handler HandlerFunc, middlewares ...echo.MiddlewareFunc)

PATCH is like echo.Group.PATCH.

func (*Router) POST

func (r *Router) POST(path string, handler HandlerFunc, middlewares ...echo.MiddlewareFunc)

POST is like echo.Group.POST.

func (*Router) PUT

func (r *Router) PUT(path string, handler HandlerFunc, middlewares ...echo.MiddlewareFunc)

PUT is like echo.Group.PUT.

Jump to

Keyboard shortcuts

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