path

package
v4.0.14 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoFlags = Flags(0x00000000)

	FlagResponseHashed           = Flags(0x00000001)
	FlagRequestDontMakeFlatModel = Flags(0x00000002)
	FlagResponseIsNotArray       = Flags(0x00000004)
	FlagUDqueriesReturnsID       = Flags(0x00000008)
	FlagWithoutCU                = Flags(0x00000010)

	FlagChainDefault    = Flags(0x00000001)
	FlagChainEnableTail = Flags(0x00000002)

	// VarName
	VarIgnore = "_"
	VarID     = "ID"
	VarGUID   = "GUID"
	VarName   = "Name"
	VarStatus = "Status"

	// Имена тегов полей в описании query параметров
	TagJSON     = "json"
	TagDB       = db.TagDB
	TagDBAlt    = db.TagDBAlt
	TagSample   = "sample"
	TagComment  = "comment"
	TagRequired = "required"
	TagReadonly = "readonly"
	TagRole     = "role"
	TagRef      = "ref"
	TagDefault  = "default"
	TagEnum     = "enum"
	TagOA       = "oa"
	TagOAtype   = "oaType"
	TagOAformat = "oaFormat"

	RolePrimary     = "primary"
	RoleKey         = "key"
	StdPrimaryField = VarID
)

Variables

This section is empty.

Functions

func GetKnownObjects

func GetKnownObjects() map[string]*Object

func SaveObject

func SaveObject(name string, obj reflect.Type, withArray bool, withCU bool) (err error)

func StructType

func StructType(v any) (t reflect.Type, err error)

Types

type Chain

type Chain struct {
	Parent        *Chains         `json:"-"`
	Flags         Flags           `json:"flags,omitempty"`
	Summary       string          `json:"summary"`
	Description   string          `json:"description"`
	Name          string          `json:"name"`
	Scope         string          `json:"scope,omitempty"`
	Params        Params          `json:"params"`
	Tokens        []*Token        `json:"tokens"`
	CacheLifetime config.Duration `json:"cacheLifetime"` // Время жизни кэша, если 0, то не использовать
}

func (*Chain) Clone

func (chain *Chain) Clone() *Chain

type Chains

type Chains struct {
	Summary           string     `json:"summary"`
	Description       string     `json:"description"`
	ParamsDescription string     `json:"paramsDescription"`
	Chains            ChainsList `json:"chains"`
	StdParams         Params     `json:"params"`
	DefaultHttpCode   int        `json:"defaultHttpCode"`
	HttpCodes         []int      `json:"httpCodes"`
	// contains filtered or unexported fields
}

func (*Chains) Clone

func (chains *Chains) Clone() *Chains

func (*Chains) Find

func (chains *Chains) Find(path []string) (matched *Chain, pathParams any, code int, err error)

func (*Chains) Len

func (chains *Chains) Len() int

func (*Chains) Less

func (chains *Chains) Less(i, j int) bool

func (*Chains) Prepare

func (chains *Chains) Prepare(m string) (err error)

func (*Chains) Swap

func (c *Chains) Swap(i, j int)

type ChainsList

type ChainsList []*Chain

func (ChainsList) Clone

func (chainsList ChainsList) Clone() ChainsList

type Flags

type Flags uint64

type Methods

type Methods map[string]*Chains

type Object

type Object struct {
	Type      reflect.Type
	ArrayType reflect.Type
	WithCU    bool
}

type Params

type Params struct {
	Flags Flags `json:"flags,omitempty"`

	InHeaders  misc.StringMap `json:"inHeaders,omitempty"`  // name -> description
	OutHeaders misc.StringMap `json:"outHeaders,omitempty"` // name -> description

	PathParamsPattern any          `json:"pathParams"`
	PathParamsType    reflect.Type `json:"-"`

	QueryParamsPattern any          `json:"queryParams"`
	QueryParamsType    reflect.Type `json:"-"`

	Request  RequestParams  `json:"requestParams"`
	Response ResponseParams `json:"responseParams"`

	DBFields *db.FieldsList `json:"-"`
}

func (*Params) ExtractFieldsFromBody

func (p *Params) ExtractFieldsFromBody(body []byte) (fieldsSlice []misc.InterfaceMap, allMessages [][]string, err error)

func (*Params) MakeTypeFlatModel

func (p *Params) MakeTypeFlatModel() (err error)

func (*Params) Prepare

func (p *Params) Prepare(m string, msgs *misc.Messages) (err error)

type ParamsObject

type ParamsObject struct {
	Name        string       `json:"name"`
	ContentType string       `json:"contentType,omitempty"`
	Pattern     any          `json:"pattern"`
	Type        reflect.Type `json:"-"`
}

type RequestParams

type RequestParams struct {
	ParamsObject    `json:"object"`
	FlatModel       misc.StringMap `json:"-"`                      // ключ - путь до поля, значение - db name
	RevFlatModel    misc.StringMap `json:"-"`                      // ключ - db name, значение - путь до поля
	RequiredFields  misc.StringMap `json:"-"`                      // обязательные поля, ключ - путь до поля, значение - db name
	ReadonlyFields  misc.StringMap `json:"-"`                      // поля только на чтение, ключ - путь до поля, значение - db name
	UniqueKeyFields []string       `json:"requestUniqueKeyFields"` // уникальные поля, первый - primary key (формально)
}

type ResponseParams

type ResponseParams struct {
	ParamsObject `json:"object"`
	SrcPattern   any          `json:"-"`
	SrcType      reflect.Type `json:"-"`
}

type Set

type Set struct {
	Flags       Flags   `json:"flags,omitempty"`
	Summary     string  `json:"summary"`
	Description string  `json:"description"`
	Methods     Methods `json:"methods"`
}

func (*Set) Clone

func (set *Set) Clone() *Set

func (*Set) Find

func (set *Set) Find(m string, path []string) (matched *Chain, pathParams any, result any, code int, err error)

func (*Set) Prepare

func (set *Set) Prepare() (err error)

type Token

type Token struct {
	Description string `json:"description"`
	Expr        string `json:"expr"`
	VarName     string `json:"varName"`
	// contains filtered or unexported fields
}

func (*Token) Clone

func (token *Token) Clone() *Token

type Vars

type Vars misc.InterfaceMap

Jump to

Keyboard shortcuts

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