echo

package
v0.0.0-...-f47fe49 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTenantFromEchoContext

func GetTenantFromEchoContext(c echo.Context) (int64, error)

GetTenantFromEchoContext tries to extract the tenant from the echo context. If the "tenantID" is missing from the context, then a default value and nil are returned as the int64 and error values.

func GetUserFromEchoContext

func GetUserFromEchoContext(c echo.Context) (*int64, error)

Types

type NoUnknownFieldsBinder

type NoUnknownFieldsBinder struct{}

struct containing our custom "bind" logic

func (*NoUnknownFieldsBinder) Bind

func (binder *NoUnknownFieldsBinder) Bind(i interface{}, c echo.Context) error

The single "Bind" method implements the echo.Binder interface.

For our custom binder we want to not allow any fields that aren't declared on the `*CreateRequest` structs. This is easily achieved by switching on the `DisallowUnknownFields` Decoder setting for unmarshaling json.

type SourcesContext

type SourcesContext struct{ echo.Context }

SourcesContext is a wrapper around the echo.Context struct so we can override methods provided by the echo library

func (*SourcesContext) Logger

func (sc *SourcesContext) Logger() echo.Logger

overriding the Logger method so we can inject custom fields into the logger. The first time this method is called (for the request) some parsing is done and stored back on the echo context. From there the fields will be present on every invocation of (*echo.Context).Logger().Debug/Info/Error/Warn

Jump to

Keyboard shortcuts

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