Documentation ¶
Overview ¶
Package value provides the value types that req uses during evaluation.
Index ¶
- func CompareType(a, b Value) error
- func Truthy(v Value) bool
- func Type(v Value) string
- type Array
- type Bool
- type Cookie
- type Duration
- type File
- type Float
- type FormData
- type Index
- type Int
- type Iterable
- type Name
- type Object
- type Request
- type Response
- type Selector
- type Stream
- type String
- type Time
- type Tuple
- type Value
- type Zero
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareType ¶
CompareType compares the types of the given values.
Types ¶
type Array ¶
type Array struct { Items []Value // contains filtered or unexported fields }
Array holds a list of values, and an underlying hash of each of the items in the array. This hash is used to perform in operations on the array.
func NewArray ¶
NewArray returns an array with the given list of values. A type check is performed on the array to ensure that they all contain the same type.
func (*Array) Get ¶
Get returns the value at the given index in the underlying array. If the given value cannot be used as an Int then an error is returned. If the index is out of bounds then the Zero value is returned.
func (*Array) MarshalJSON ¶
type Bool ¶
type Bool struct {
Value bool
}
Bool is the value for boolean types.
func (Bool) MarshalJSON ¶
type Duration ¶ added in v1.1.0
func ToDuration ¶ added in v1.1.0
type File ¶
File is the value for an open file. This holds the underlying handle to the file. The file value can be used as a stream.
type FormData ¶
FormData is the value for data encoded as multipart/form-data. This holds the Content-Type of the data, which would be set in a request header, and the data itself.
func ToFormData ¶
ToFormData attempts to type assert the given value to FormData.
type Index ¶
type Index interface { // Has checks to see if the given Value exists in the underlying index. Has(Value) bool Get(Value) (Value, error) Set(bool, Value, Value) error }
Index represents a Value that can be indexed, such as an Object or an Array.
type Int ¶
type Int struct {
Value int64
}
Int is the value for int types.
func (Int) MarshalJSON ¶
type Iterable ¶
type Iterable interface { // Next returns the key and value for the value being iterated over. The // error returned will be io.EOF when the end of the iterable has been // reached. Next() (Value, Value, error) }
func ToIterable ¶
ToIterable attempts to asset the given Value to an Iterable.
type Name ¶
type Name struct {
Value string
}
Name is the value for an identifier, such as a variable declaration or key.
type Object ¶
type Object struct { Order []string // The order in which the keys should be iterated. Pairs map[string]Value // contains filtered or unexported fields }
Object holds a list of values indexed under a string.
func (*Object) Get ¶
Get returns the value at the given index, if that value is a string. If there is no value at the given index, then Zero is returned.
func (*Object) Has ¶
Has checks to see if the current object has the current value, if that given value is a string.
func (*Object) MarshalJSON ¶
type Request ¶
type Request struct { *http.Request Transport http.RoundTripper }
Request is the value for an HTTP request. This holds the underlying handle to the request.
type Response ¶
Response is the value for an HTTP response. This holds the underlying handle to the response.
type Selector ¶
Selector represents a Value that has fields that can be accessed via a dot.
func ToSelector ¶
ToSelector attempts to assert the given Value to a Selector.
type Stream ¶
Stream represents a stream of data that can be read. This would either be a Request/Response body or a File.
func BufferStream ¶
BufferStream returns a new stream for reading data from a location in memory.
type String ¶
type String struct {
Value string
}
String is the value for string types.
func (String) MarshalJSON ¶
type Tuple ¶ added in v1.1.0
type Tuple struct {
// contains filtered or unexported fields
}
Tuple holds two different values that allows for the typle to be used as either value.
type Value ¶
type Value interface { // String formats the Value into a string. The returned string is suitable // for display in a REPL. For example, strings are quoted. String() string // Sprint formats the Value into a string. This differs from String, in // that the returned string may not be suitable for display in a REPL. // For example, strings are not quoted, and the entire contents of Streams // are returned. Sprint() string // contains filtered or unexported methods }
func Compare ¶
Compare performs the given operation between the two values and returns the result of that comparison. This returned value will be a truthy value.
func DecodeJSON ¶
DecodeJSON attempts to decode all of the data in the given reader to JSON. The returned value will either be of type String, Int, Bool, Array, Object, or Zero depending on the JSON string being decoded.
type Zero ¶
type Zero struct{}
Zero is the value that represents a zero value. The zero value can be compared against any other type that also has an underlying zero value.