directive

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsArrayOfTypes

func IsArrayOfTypes(b bytes.Bytes) bool

func IsHTTPResponseCode

func IsHTTPResponseCode(s string) bool

func IsStartWithDirective

func IsStartWithDirective(b bytes.Bytes) bool

Types

type Coords

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

func NewCoords

func NewCoords(f *fs.File, begin, end bytes.Index) Coords

func (Coords) Begin

func (c Coords) Begin() bytes.Index

func (Coords) File

func (c Coords) File() *fs.File

func (Coords) IsSet

func (c Coords) IsSet() bool

func (Coords) Read

func (c Coords) Read() bytes.Bytes

func (Coords) String

func (c Coords) String() string

type Directive

type Directive struct {
	Annotation string

	Keyword string // only for Responses (have multiple keywords), for others should match type.

	BodyCoords Coords
	Parent     *Directive
	Children   []*Directive

	// HasExplicitContext true if directive's context is opened explicitly with parentheses.
	HasExplicitContext bool
	// contains filtered or unexported fields
}

Directive represents all info about some Directive

func New

func New(e Enumeration, keywordCoords Coords) *Directive

func NewWithCallStack

func NewWithCallStack(e Enumeration, keywordCoords Coords, includeTracer IncludeTracer) *Directive

func (*Directive) AppendChild

func (d *Directive) AppendChild(child *Directive)

func (*Directive) AppendParameter

func (d *Directive) AppendParameter(b bytes.Bytes) error

func (*Directive) AppendUnnamedParameter

func (d *Directive) AppendUnnamedParameter(v string)

func (Directive) BodyError

func (d Directive) BodyError(msg string) *jerr.JApiError

func (Directive) BodyErrorIndex

func (d Directive) BodyErrorIndex(msg string, i uint) *jerr.JApiError

func (Directive) CopyWoParentAndChildren

func (d Directive) CopyWoParentAndChildren() Directive

func (Directive) Equal

func (d Directive) Equal(d2 Directive) bool

func (Directive) HTTPMethod

func (d Directive) HTTPMethod() (Enumeration, error)

func (Directive) HasNamedParameter

func (d Directive) HasNamedParameter() bool

func (Directive) HasUnnamedParameter

func (d Directive) HasUnnamedParameter() bool

func (Directive) JsonRpcMethodName

func (d Directive) JsonRpcMethodName() (string, error)

func (Directive) KeywordError

func (d Directive) KeywordError(msg string) *jerr.JApiError

func (Directive) NamedParameter

func (d Directive) NamedParameter(k string) string

func (Directive) ParameterError

func (d Directive) ParameterError(msg string) *jerr.JApiError

func (Directive) Path

func (d Directive) Path() (string, error)

func (*Directive) SetNamedParameter

func (d *Directive) SetNamedParameter(k, v string) error

func (Directive) String

func (d Directive) String() string

func (Directive) Type

func (d Directive) Type() Enumeration

func (Directive) UnnamedParameter

func (d Directive) UnnamedParameter() []string

func (Directive) UnnamedParametersLen

func (d Directive) UnnamedParametersLen() int

type Directives

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

Directives represent available directives. gen:OrderedMap

func (*Directives) Each

func (m *Directives) Each(fn eachDirectivesFunc) error

Each iterates and perform given function on each item in the map.

func (*Directives) EachReverse

func (m *Directives) EachReverse(fn eachDirectivesFunc) error

EachReverse act almost the same as Each but in reverse order.

func (*Directives) EachSafe

func (m *Directives) EachSafe(fn eachSafeDirectivesFunc)

func (*Directives) Find

func (m *Directives) Find(fn findDirectivesFunc) (DirectivesItem, bool)

Find finds first matched item from the map.

func (*Directives) Get

func (m *Directives) Get(k string) (*Directive, bool)

Get gets a value by key.

func (*Directives) GetValue

func (m *Directives) GetValue(k string) *Directive

GetValue gets a value by key.

func (*Directives) Has

func (m *Directives) Has(k string) bool

Has checks that specified key is set.

func (*Directives) Len

func (m *Directives) Len() int

Len returns count of values.

func (*Directives) Map

func (m *Directives) Map(fn mapDirectivesFunc) error

Map iterates and changes values in the map.

func (*Directives) MarshalJSON

func (m *Directives) MarshalJSON() ([]byte, error)

func (*Directives) Set

func (m *Directives) Set(k string, v *Directive)

Set sets a value with specified key.

func (*Directives) SetToTop

func (m *Directives) SetToTop(k string, v *Directive)

SetToTop do the same as Set, but new key will be placed on top of the order map.

func (*Directives) Update

func (m *Directives) Update(k string, fn func(v *Directive) *Directive)

Update updates a value with specified key.

type DirectivesItem

type DirectivesItem struct {
	Key   string
	Value *Directive
}

DirectivesItem represent single data from the Directives.

type Enumeration

type Enumeration int
const (
	Jsight Enumeration = iota
	Info
	Title
	Version
	Description
	Server
	BaseURL
	URL
	Get
	Post
	Put
	Patch
	Delete
	Body
	Request
	HTTPResponseCode
	Path
	Headers
	Query
	Type
	Enum
	Macro
	Paste

	// Include directive.
	// This directive will be processed before we build a directive tree, so you
	// won't see it.
	Include

	Protocol
	Method
	Params
	Result
	TAG
	Tags
)

func NewDirectiveType

func NewDirectiveType(s string) (Enumeration, error)

func (Enumeration) IsAllowedForDirectiveContext

func (de Enumeration) IsAllowedForDirectiveContext(child Enumeration) bool

func (Enumeration) IsAllowedForRootContext

func (de Enumeration) IsAllowedForRootContext() bool

func (Enumeration) IsHTTPRequestMethod

func (de Enumeration) IsHTTPRequestMethod() bool

func (Enumeration) String

func (de Enumeration) String() string

type IncludeTracer

type IncludeTracer interface {
	// AddIncludeTraceToError adds proper trace to error.
	AddIncludeTraceToError(je *jerr.JApiError)
}

IncludeTracer represent the directive's call stack.

Jump to

Keyboard shortcuts

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