v1

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: GPL-3.0 Imports: 18 Imported by: 5

Documentation

Index

Constants

View Source
const (
	StructTagName = "name"
	StructTagSQL  = "sql"
)

Variables

View Source
var (
	FieldNotFound = errors.New("field was not found")
)

Functions

func Default404Handler

func Default404Handler(app App) libhttp.Service

func DefaultLongPath

func DefaultLongPath(module Module, route Route) string

func GetCurrentDir

func GetCurrentDir() (dirAbsPath string, err error)

func GetGoEnv

func GetGoEnv() (map[string]string, error)

func GetPackagePath

func GetPackagePath(i interface{}) string

Types

type App

type App struct {
	Addr    string            `json:"addr"`
	Config  Config            `json:"config"`
	Modules map[string]Module `json:"modules"`
	Router  *libhttp.Router
	Debug   bool
	Verbose bool
}

func NewApp

func NewApp(addr string, config Config, verbose, debug bool, modules ...Module) App

func (App) PrintConfig

func (app App) PrintConfig()

func (App) PrintRoutes

func (app App) PrintRoutes(addr string)

func (App) Register

func (app App) Register(module Module)

func (App) Routes

func (app App) Routes() map[string]Route

type Config

type Config struct {
	EnableAuthOnOptions    bool     `json:"enable_auth_on_options"`
	TokenExtractors        []string `json:"token_extractors" validate:"> 	one_of=headers,params"` // allowed values are "headers" and "params"
	OAuthJsonWebKeySetsUrl string   `json:"oauth_json_web_key_sets_url"`
	OAuthIssuer            string   `json:"oauth_issuer"`
	OAuthAudience          string   `json:"oauth_audience"`
}

func ParseConfig

func ParseConfig(path string) (config Config, err error)

type DefaultEntity

type DefaultEntity struct {
	ID uuid.UUID `persistence:"id"`
}

func (*DefaultEntity) Index

func (e *DefaultEntity) Index() uuid.UUID

func (*DefaultEntity) SetIndex

func (e *DefaultEntity) SetIndex(u uuid.UUID)

type Entity

type Entity interface {
	Index() uuid.UUID
	SetIndex(u uuid.UUID)
	Name() string
	Type() reflect.Type
	Value(key string) (interface{}, error)
}

type GenericResponse

type GenericResponse struct {
	Message interface{} `json:"message"`
	Error   *string     `json:"error,omitempty"`
}

type Module

type Module interface {
	Version() string
	Namespace() string
	Routes() map[string]Route
	LongPath(route Route) string
}

type Pipeline

type Pipeline interface {
	Consume(objs ...interface{}) (interface{}, error)
	Init(objs ...interface{}) (interface{}, error)
}

func LoadPipeline

func LoadPipeline(path string) (Pipeline, error)

type Repository

type Repository interface {
	CreateTable(i Entity, ifNotExist bool) error
	DropTable(i Entity, ifExists bool) error
	Save(i Entity, fields ...string) error
	Update(i Entity, fields ...string) error
	Get(i uuid.UUID) (Entity, error)
	List() []Entity
	Delete(i Entity) (bool, error)
}

type Route

type Route struct {
	Path               string               `json:"-"`
	Method             string               `json:"method"`
	CurlExample        string               `json:"curl_example"`
	Validator          *Validator           `json:"-"`
	MultiPartValidator *Validator           `json:"-"`
	TokenValidator     ValidatorWithService `json:"-"`
	Service            Service              `json:"-"`
}

type Service

type Service func(app App) libhttp.Service

type Validator

type Validator func(request libhttp.Request) (interface{}, error)

func GenerateJSONValidator

func GenerateJSONValidator(i interface{}) *Validator

func GenerateMultipartValidator

func GenerateMultipartValidator(i interface{}, maxMemoryBytes int64) *Validator

type ValidatorWithService

type ValidatorWithService libhttp.Filter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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