domain

package
v5.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilterByRegexArgRegex = "regex"
	FilterByRegexArgPath  = "path"
)
View Source
const (
	FromMethod   string = "from"
	ToMethod            = "to"
	IntoMethod          = "into"
	UpdateMethod        = "update"
	DeleteMethod        = "delete"
)

Methods available to be used in query statements.

View Source
const MatchArgRegex = "regex"

Variables

View Source
var ErrRequestTimeout = errors.New("request timed out")

ErrRequestTimeout is the error returned by HTTPClient when a HTTP call fails due to the request exceeding the timeout defined in HTTPRequest.

Functions

This section is empty.

Types

type Arg added in v5.3.0

type Arg struct {
	Name  string
	Value interface{}
}

type AsBody

type AsBody struct {
	Value interface{}
}

AsBody is a Function that define a `with` parameter as the request body for statements using to, into or patch methods.

func (AsBody) Argument added in v5.3.0

func (ab AsBody) Argument(name string) Arg

Argument fetches a AsBody argument by name

func (AsBody) Arguments added in v5.3.0

func (ab AsBody) Arguments() []Arg

Arguments return the arguments provided to AsBody function

func (AsBody) Map

func (ab AsBody) Map(fn func(target interface{}) interface{}) Function

Map apply the given function to the Target value preserving the AsBody as a wrapper.

func (AsBody) SetArgument added in v5.3.0

func (ab AsBody) SetArgument(name string, value interface{}) Function

SetArgument immutably updates the value of an argument by name

func (AsBody) Target

func (ab AsBody) Target() interface{}

Target return the value upon which AsBody will be applied.

type AsQuery added in v5.4.0

type AsQuery struct {
	Value interface{}
}

NoExplode is a Function that disable object explosion when resolving with values.

func (AsQuery) Argument added in v5.4.0

func (f AsQuery) Argument(name string) Arg

Argument fetches a AsQuery argument by name

func (AsQuery) Arguments added in v5.4.0

func (f AsQuery) Arguments() []Arg

Arguments return the arguments provided to AsQuery function

func (AsQuery) Map added in v5.4.0

func (f AsQuery) Map(fn func(target interface{}) interface{}) Function

Map apply the given function to the Target value preserving the AsQuery as a wrapper.

func (AsQuery) SetArgument added in v5.4.0

func (f AsQuery) SetArgument(name string, value interface{}) Function

SetArgument immutably updates the value of an argument by name

func (AsQuery) Target added in v5.4.0

func (f AsQuery) Target() interface{}

Target return the value upon which AsQuery will be applied.

type Base64

type Base64 struct {
	Value interface{}
}

Base64 is a Function that encode the target value as base64.

func (Base64) Argument added in v5.3.0

func (b Base64) Argument(name string) Arg

Argument fetches a Base64 argument by name

func (Base64) Arguments added in v5.3.0

func (b Base64) Arguments() []Arg

Arguments return the arguments provided to Base64 function

func (Base64) Map

func (b Base64) Map(fn func(target interface{}) interface{}) Function

Map apply the given function to the Target value preserving the Base64 as a wrapper.

func (Base64) SetArgument added in v5.3.0

func (b Base64) SetArgument(name string, value interface{}) Function

SetArgument immutably updates the value of an argument by name

func (Base64) Target

func (b Base64) Target() interface{}

Target return the value upon which Base64 will be applied.

type CacheControl

type CacheControl struct {
	MaxAge  interface{}
	SMaxAge interface{}
}

CacheControl is the internal representation of the `max-age` and `s-max-age` clauses.

type Chain

type Chain []interface{}

Chain is the internal representation of a chain parameter value.

type Debugging

type Debugging struct {
	Method          string
	Url             string
	RequestHeaders  map[string]string
	ResponseHeaders map[string]string
	Params          map[string]interface{}
	RequestBody     interface{}
	ResponseTime    int64
}

Debugging represents the collection of information about the statement result. This is only used when the client enable it during query execution.

type DependsOn added in v5.1.0

type DependsOn struct {
	Target   string
	Resolved bool
}

DependsOn is the internal representation of the `depends-on` clause.

type Details

type Details struct {
	Status       int
	Success      bool
	IgnoreErrors bool
	CacheControl restql.ResourceCacheControl
	Debug        *Debugging
}

Details represents metadata about the statement result.

type EnvSource

type EnvSource interface {
	GetString(key string) string
	GetAll() map[string]string
}

EnvSource expose access to environment variables.

type FilterByRegex added in v5.3.0

type FilterByRegex struct {
	Value interface{}
	Args  []Arg
}

NoExplode is a Function that disable object explosion when resolving with values.

func NewFilterByRegex added in v5.3.0

func NewFilterByRegex(target, path, regex interface{}) FilterByRegex

func (FilterByRegex) Argument added in v5.3.0

func (f FilterByRegex) Argument(name string) Arg

Argument fetches a FilterByRegex argument by name

func (FilterByRegex) Arguments added in v5.3.0

func (f FilterByRegex) Arguments() []Arg

Arguments return the arguments provided to FilterByRegex function

func (FilterByRegex) Map added in v5.3.0

func (f FilterByRegex) Map(fn func(target interface{}) interface{}) Function

Map apply the given function to the Target value preserving the FilterByRegex as a wrapper.

func (FilterByRegex) SetArgument added in v5.3.0

func (f FilterByRegex) SetArgument(name string, value interface{}) Function

SetArgument immutably updates the value of an argument by name

func (FilterByRegex) Target added in v5.3.0

func (f FilterByRegex) Target() interface{}

Target return the value upon which FilterByRegex will be applied.

type Flatten

type Flatten struct {
	Value interface{}
}

Flatten is a Function that encode the target value as a plain list of value.

func (Flatten) Argument added in v5.3.0

func (f Flatten) Argument(name string) Arg

Argument fetches a Flatten argument by name

func (Flatten) Arguments added in v5.3.0

func (f Flatten) Arguments() []Arg

Arguments return the arguments provided to Flatten function

func (Flatten) Map

func (f Flatten) Map(fn func(target interface{}) interface{}) Function

Map apply the given function to the Target value preserving the Flatten as a wrapper.

func (Flatten) SetArgument added in v5.3.0

func (f Flatten) SetArgument(name string, value interface{}) Function

SetArgument immutably updates the value of an argument by name

func (Flatten) Target

func (f Flatten) Target() interface{}

Target return the value upon which Flatten will be applied.

type Function

type Function interface {
	Target() interface{}
	Arguments() []Arg
	Argument(string) Arg
	SetArgument(string, interface{}) Function
	Map(fn func(target interface{}) interface{}) Function
}

Function is the interface implemented by types that provide encoding, filters and special behaviour through the apply operator.

Target returns the value upon which the function will be applied. Arguments return the arguments provided to the Function Argument fetches a Function argument by name SetArgument immutably updates the value of an argument by name Map uses a function to transform the target value preserving the current Function type wrapping it.

type HTTPClient

type HTTPClient interface {
	Do(ctx context.Context, request restql.HTTPRequest) (restql.HTTPResponse, error)
}

HTTPClient is the interface that wrap the method Do

Do takes an HTTPRequest and execute it respecting the cancellation signal from the given Context.

type JSON

type JSON struct {
	Value interface{}
}

JSON is a Function that encode the target value as json.

func (JSON) Argument added in v5.3.0

func (j JSON) Argument(name string) Arg

Argument fetches a JSON argument by name

func (JSON) Arguments added in v5.3.0

func (j JSON) Arguments() []Arg

Argumetns return the arguments provided to JSON function

func (JSON) Map

func (j JSON) Map(fn func(target interface{}) interface{}) Function

Map apply the given function to the Target value preserving the JSON as a wrapper.

func (JSON) SetArgument added in v5.3.0

func (j JSON) SetArgument(name string, value interface{}) Function

SetArgument immutably updates the value of an argument by name

func (JSON) Target

func (j JSON) Target() interface{}

Target return the value upon which JSON will be applied.

type Match

type Match struct {
	Value interface{}
	Arg   interface{}
	Args  []Arg
}

Match is a Function that select values from the statement result based on the given Arg.

func (Match) Argument added in v5.3.0

func (m Match) Argument(name string) Arg

Argument fetches a Match argument by name

func (Match) Arguments added in v5.3.0

func (m Match) Arguments() []Arg

Arguments return the arguments provided to Match function

func (Match) Map

func (m Match) Map(fn func(target interface{}) interface{}) Function

Map apply the given function to the Target value preserving the Match as a wrapper.

func (Match) SetArgument added in v5.3.0

func (m Match) SetArgument(name string, argValue interface{}) Function

SetArgument immutably updates the value of an argument by name

func (Match) Target

func (m Match) Target() interface{}

Target return the value upon which Match will be applied.

type Modifiers

type Modifiers map[string]interface{}

Modifiers is the internal representation of the `use` clause.

type NoExplode

type NoExplode struct {
	Value interface{}
}

NoExplode is a Function that disable object explosion when resolving with values.

func (NoExplode) Argument added in v5.3.0

func (f NoExplode) Argument(name string) Arg

Argument fetches a NoExplode argument by name

func (NoExplode) Arguments added in v5.3.0

func (f NoExplode) Arguments() []Arg

Arguments return the arguments provided to NoExplode function

func (NoExplode) Map

func (f NoExplode) Map(fn func(target interface{}) interface{}) Function

Map apply the given function to the Target value preserving the NoExplode as a wrapper.

func (NoExplode) SetArgument added in v5.3.0

func (f NoExplode) SetArgument(name string, value interface{}) Function

SetArgument immutably updates the value of an argument by name

func (NoExplode) Target

func (f NoExplode) Target() interface{}

Target return the value upon which NoExplode will be applied.

type NoMultiplex

type NoMultiplex struct {
	Value interface{}
}

NoMultiplex is a Function that disable request multiplexing of statements with list parameters.

func (NoMultiplex) Argument added in v5.3.0

func (nm NoMultiplex) Argument(name string) Arg

Argument fetches a NoMultiplex argument by name

func (NoMultiplex) Arguments added in v5.3.0

func (nm NoMultiplex) Arguments() []Arg

Arguments return the arguments provided to NoMultiplex function

func (NoMultiplex) Map

func (nm NoMultiplex) Map(fn func(target interface{}) interface{}) Function

Map apply the given function to the Target value preserving the NoMultiplex as a wrapper.

func (NoMultiplex) SetArgument added in v5.3.0

func (nm NoMultiplex) SetArgument(name string, value interface{}) Function

SetArgument immutably updates the value of an argument by name

func (NoMultiplex) Target

func (nm NoMultiplex) Target() interface{}

Target return the value upon which NoMultiplex will be applied.

type Params

type Params struct {
	Body   interface{}
	Values map[string]interface{}
}

Params is the internal representation of the `with` clause.

type Query

type Query struct {
	Use        Modifiers
	Statements []Statement
}

Query is the internal representation of the restQL language.

type ResourceID

type ResourceID string

ResourceID is an unique identifier used by a statement. If an alias is present, it is used. Otherwise, the resource name.

func NewResourceID

func NewResourceID(statement Statement) ResourceID

NewResourceID make a ResourceID from a Statement.

type Resources

type Resources map[ResourceID]interface{}

Resources represents the index of statements already resolved or to be resolved.

func NewResources

func NewResources(statements []Statement) Resources

NewResources constructs a Resources collection from a slice of statements.

type Statement

type Statement struct {
	Method       string
	Resource     string
	Alias        string
	In           []string
	DependsOn    DependsOn
	Headers      map[string]interface{}
	Timeout      interface{}
	With         Params
	Only         []interface{}
	Hidden       bool
	CacheControl CacheControl
	IgnoreErrors bool
}

Statement is the internal representation of a query statement.

type Variable

type Variable struct {
	Target string
}

Variable is the internal representation of a variable parameter value.

Jump to

Keyboard shortcuts

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