common

package module
v0.0.0-...-16b35d8 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetService

func GetService(serviceName ServiceName, serviceMap *InjectedServicesMap) (interface{}, bool)

GetService It returns the service from the injected service map

func InitModule

func InitModule(modules []*Module, moduleParams *InitModuleParams, basePath *string)

InitModule It initializes the module by registering routes

func NewRequestValidator

func NewRequestValidator() echo.Validator

NewRequestValidator creates a new RequestValidator

func UploadHandler

func UploadHandler(context AppContext, s3Config S3Uploader.S3) (*S3Uploader.UploadId, error)

UploadHandler Default upload handler for thunderbyte Checks for the form field with name="file". Returns an error if it does not find that field

Types

type AppContext

type AppContext struct {
	RequestContext    RequestContext
	HTTPServerContext echo.Context
	DBConfig          *database.DBConfig
	Redis             *redis.Redis
	SMTPPool          *smtppool.Pool
	Logger            *logf.Logger
	K                 *koanf.Koanf
	Q                 interface{}
}

func (*AppContext) SetCookie

func (ctx *AppContext) SetCookie(cookie *http.Cookie)

type ControllerConfig

type ControllerConfig struct {
	ModulePath  RoutePath
	Controllers Controllers
	JWTSecret   string // If present then JWT middleware will be added on the module
}

type Controllers

type Controllers map[RoutePath]HTTPMethodConfig

type HTTPError

type HTTPError struct {
	// Code It is the HTTP status code used by standard http package in Go
	Code int
	// Message It is the error message set by the caller
	Message string
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

type HTTPMethod

type HTTPMethod int
const (
	GET HTTPMethod = iota
	POST
	PUT
	DELETE
	PATCH
	OPTIONS
	HEAD
	TRACE
	CONNECT
)

type HTTPMethodConfig

type HTTPMethodConfig map[HTTPMethod]HTTPMethodHandlerConfig

type HTTPMethodHandler

type HTTPMethodHandler func(context AppContext, injectedServicesMap *InjectedServicesMap) (interface{}, *HTTPError)

type HTTPMethodHandlerConfig

type HTTPMethodHandlerConfig struct {
	Handler   HTTPMethodHandler
	JWTSecret string // If present then JWT middleware will be added on the handler
}

type Headers

type Headers map[string][]string

type InitModuleParams

type InitModuleParams struct {
	Srv      *echo.Echo
	DBConfig *database.DBConfig
	Redis    *redis.Redis
	K        *koanf.Koanf
	SMTPPool *smtppool.Pool
	Logger   *logf.Logger
}

type InjectedServicesMap

type InjectedServicesMap map[ServiceName]interface{}

type Module

type Module struct {
	E                *echo.Echo
	L                *logf.Logger
	ControllerConfig *ControllerConfig
	Providers        []interface{}
	Imports          []*Module
}

type QueryParams

type QueryParams map[string][]string

type RequestContext

type RequestContext struct {
	Body        interface{}
	QueryParams QueryParams
	Path        string
	Headers     Headers
}

type RequestValidator

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

func (*RequestValidator) Validate

func (cv *RequestValidator) Validate(i interface{}) error

type RoutePath

type RoutePath string

type ServiceName

type ServiceName string

Jump to

Keyboard shortcuts

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