Documentation ¶
Index ¶
- Constants
- Variables
- func ParseExpandOption(queue *tokenQueue, item *ExpandItem) error
- func ParseName(segment string) string
- func ParseUrlPath(path string) (*GoDataSegment, *GoDataSegment, error)
- func SemanticizeExpandQuery(expand *GoDataExpandQuery, service *GoDataService, entity *GoDataEntityType) error
- func SemanticizeFilterQuery(filter *GoDataFilterQuery, service *GoDataService, entity *GoDataEntityType) error
- func SemanticizeOrderByQuery(orderby *GoDataOrderByQuery, service *GoDataService, entity *GoDataEntityType) error
- func SemanticizePathSegment(segment *GoDataSegment, service *GoDataService) error
- func SemanticizeRequest(req *GoDataRequest, service *GoDataService) error
- func SemanticizeSelectQuery(sel *GoDataSelectQuery, service *GoDataService, entity *GoDataEntityType) error
- type DuplicateQueryParameterError
- type ExpandItem
- type ExpandTokenType
- type ExpressionParser
- func (p *ExpressionParser) ParseExpressionString(expression string) (*GoDataExpression, error)
- func (p *ExpressionParser) ParseOrderByString(orderby string) (*GoDataOrderByQuery, error)
- func (p *ExpressionParser) SemanticizeExpression(expression *GoDataExpression, service *GoDataService, entity *GoDataEntityType) error
- type ExpressionTokenType
- type Function
- type GoDataAction
- type GoDataActionImport
- type GoDataAnnotation
- type GoDataAnnotations
- type GoDataApplyQuery
- type GoDataComplexType
- type GoDataCountQuery
- type GoDataEntityContainer
- type GoDataEntitySet
- type GoDataEntityType
- type GoDataEnumType
- type GoDataError
- func BadRequestError(message string) *GoDataError
- func GoneError(message string) *GoDataError
- func InternalServerError(message string) *GoDataError
- func MethodNotAllowedError(message string) *GoDataError
- func NotFoundError(message string) *GoDataError
- func NotImplementedError(message string) *GoDataError
- func PreconditionFailedError(message string) *GoDataError
- type GoDataExpandQuery
- type GoDataExpression
- type GoDataFilterQuery
- type GoDataFormatQuery
- type GoDataFunction
- type GoDataFunctionImport
- type GoDataIdentifier
- type GoDataInclude
- type GoDataIncludeAnnotations
- type GoDataInlineCountQuery
- type GoDataKey
- type GoDataMember
- type GoDataMetadata
- type GoDataNavigationProperty
- type GoDataNavigationPropertyBinding
- type GoDataOnDelete
- type GoDataOrderByQuery
- type GoDataParameter
- type GoDataProperty
- type GoDataPropertyRef
- type GoDataProvider
- type GoDataQuery
- type GoDataReference
- type GoDataReferentialConstraint
- type GoDataRequest
- type GoDataResponse
- type GoDataResponseField
- type GoDataReturnType
- type GoDataSchema
- type GoDataSearchQuery
- type GoDataSegment
- type GoDataSelectQuery
- type GoDataService
- func (service *GoDataService) GoDataHTTPHandler(w http.ResponseWriter, r *http.Request)
- func (service *GoDataService) ListenAndServe(addr string)
- func (service *GoDataService) LookupEntitySet(name string) (*GoDataEntitySet, error)
- func (service *GoDataService) LookupEntityType(name string) (*GoDataEntityType, error)
- type GoDataServices
- type GoDataSingleton
- type GoDataSkipQuery
- type GoDataTerm
- type GoDataTopQuery
- type GoDataTypeDefinition
- type ListExprToken
- type Operator
- type OrderByItem
- type ParseNode
- type Parser
- func (p *Parser) DefineFunction(token string, params []int) *Function
- func (p *Parser) DefineOperator(token string, operands, assoc, precedence int) *Operator
- func (p *Parser) InfixToPostfix(tokens []*Token) (*tokenQueue, error)
- func (p *Parser) PostfixToTree(queue *tokenQueue) (*ParseNode, error)
- func (p *Parser) WithLiteralToken(token TokenType) *Parser
- type SearchTokenType
- type SelectItem
- type SemanticType
- type Token
- type TokenHandler
- type TokenMatcher
- type TokenType
- type Tokenizer
- func (t *Tokenizer) Add(pattern string, token TokenType)
- func (t *Tokenizer) AddWithSubstituteFunc(pattern string, token TokenType, subst func(string) string)
- func (t *Tokenizer) Ignore(pattern string, token TokenType)
- func (t *Tokenizer) Tokenize(target string) ([]*Token, error)
- func (t *Tokenizer) TokenizeBytes(target []byte) ([]*Token, error)
- type UnsupportedQueryParameterError
Constants ¶
const ( ALLPAGES = "allpages" NONE = "none" )
const ( GoDataString = "Edm.String" GoDataInt16 = "Edm.Int16" GoDataInt32 = "Edm.Int32" GoDataInt64 = "Edm.Int64" GoDataDecimal = "Edm.Decimal" GoDataBinary = "Edm.Binary" GoDataBoolean = "Edm.Boolean" GoDataTimeOfDay = "Edm.TimeOfDay" GoDataDate = "Edm.Date" GoDataDateTimeOffset = "Edm.DateTimeOffset" )
const ( ASC = "asc" DESC = "desc" )
const ( OpAssociationLeft int = iota OpAssociationRight OpAssociationNone )
const ( TokenListExpr = "list" // TokenComma is the default separator for function arguments. TokenComma = "," TokenOpenParen = "(" TokenCloseParen = ")" )
const ( RequestKindUnknown int = iota RequestKindMetadata RequestKindService RequestKindEntity RequestKindCollection RequestKindSingleton RequestKindProperty RequestKindPropertyValue RequestKindRef RequestKindCount )
const ( ODataFieldContext string = "@odata.context" ODataFieldCount string = "@odata.count" ODataFieldValue string = "value" )
Variables ¶
var GlobalExpandTokenizer = ExpandTokenizer()
var GlobalExpressionParser = NewExpressionParser()
var GlobalExpressionTokenizer = NewExpressionTokenizer()
var GlobalFilterParser = NewExpressionParser()
var GlobalFilterTokenizer = NewExpressionTokenizer()
var GlobalSearchParser = SearchParser()
var GlobalSearchTokenizer = SearchTokenizer()
Functions ¶
func ParseExpandOption ¶
func ParseExpandOption(queue *tokenQueue, item *ExpandItem) error
func ParseUrlPath ¶
func ParseUrlPath(path string) (*GoDataSegment, *GoDataSegment, error)
func SemanticizeExpandQuery ¶
func SemanticizeExpandQuery( expand *GoDataExpandQuery, service *GoDataService, entity *GoDataEntityType, ) error
func SemanticizeFilterQuery ¶
func SemanticizeFilterQuery( filter *GoDataFilterQuery, service *GoDataService, entity *GoDataEntityType, ) error
func SemanticizeOrderByQuery ¶
func SemanticizeOrderByQuery(orderby *GoDataOrderByQuery, service *GoDataService, entity *GoDataEntityType) error
func SemanticizePathSegment ¶
func SemanticizePathSegment(segment *GoDataSegment, service *GoDataService) error
func SemanticizeRequest ¶
func SemanticizeRequest(req *GoDataRequest, service *GoDataService) error
Compare a request to a given service, and validate the semantics and update the request with semantics included
func SemanticizeSelectQuery ¶
func SemanticizeSelectQuery(sel *GoDataSelectQuery, service *GoDataService, entity *GoDataEntityType) error
Types ¶
type DuplicateQueryParameterError ¶
type DuplicateQueryParameterError struct {
Parameter string
}
func (*DuplicateQueryParameterError) Error ¶
func (err *DuplicateQueryParameterError) Error() string
type ExpandItem ¶
type ExpandItem struct { Path []*Token Filter *GoDataFilterQuery At *GoDataFilterQuery Search *GoDataSearchQuery OrderBy *GoDataOrderByQuery Skip *GoDataSkipQuery Top *GoDataTopQuery Select *GoDataSelectQuery Expand *GoDataExpandQuery Levels int }
Represents an item to expand in an OData query. Tracks the path of the entity to expand and also the filter, levels, and reference options, etc.
func ParseExpandItem ¶
func ParseExpandItem(input tokenQueue) (*ExpandItem, error)
type ExpandTokenType ¶
type ExpandTokenType int
const ( ExpandTokenOpenParen ExpandTokenType = iota ExpandTokenCloseParen ExpandTokenComma ExpandTokenSemicolon ExpandTokenEquals ExpandTokenLiteral )
func (ExpandTokenType) Value ¶
func (e ExpandTokenType) Value() int
type ExpressionParser ¶
type ExpressionParser struct { *Parser ExpectBoolExpr bool // Request expression to validate it is a boolean expression. // contains filtered or unexported fields }
ExpressionParser is a ODATA expression parser.
func NewExpressionParser ¶
func NewExpressionParser() *ExpressionParser
func (*ExpressionParser) ParseExpressionString ¶
func (p *ExpressionParser) ParseExpressionString(expression string) (*GoDataExpression, error)
ParseExpressionString converts a ODATA expression input string into a parse tree that can be used by providers to create a response. Expressions can be used within $filter and $orderby query options.
func (*ExpressionParser) ParseOrderByString ¶
func (p *ExpressionParser) ParseOrderByString(orderby string) (*GoDataOrderByQuery, error)
The value of the $orderby System Query option contains a comma-separated list of expressions whose primitive result values are used to sort the items. The service MUST order by the specified property in ascending order. 4.01 services MUST support case-insensitive values for asc and desc.
func (*ExpressionParser) SemanticizeExpression ¶
func (p *ExpressionParser) SemanticizeExpression( expression *GoDataExpression, service *GoDataService, entity *GoDataEntityType, ) error
type ExpressionTokenType ¶
type ExpressionTokenType int
const ( ExpressionTokenOpenParen ExpressionTokenType = iota // Open parenthesis - parenthesis expression, list expression, or path segment selector. ExpressionTokenCloseParen // Close parenthesis ExpressionTokenWhitespace // white space token ExpressionTokenColon // Function arg separator for 'any(v:boolExpr)' and 'all(v:boolExpr)' lambda operators ExpressionTokenComma // [5] List delimiter and function argument delimiter. ExpressionTokenLogical // eq|ne|gt|ge|lt|le|and|or|not|has|in ExpressionTokenOp // add|sub|mul|divby|div|mod ExpressionTokenFunc // Function, e.g. contains, substring... ExpressionTokenLambda // [10] any(), all() lambda functions ExpressionTokenNull // ExpressionTokenIt // The '$it' token ExpressionTokenRoot // The '$root' token ExpressionTokenFloat // A floating point value. ExpressionTokenInteger // [15] An integer value ExpressionTokenString // SQUOTE *( SQUOTE-in-string / pchar-no-SQUOTE ) SQUOTE ExpressionTokenDate // A date value ExpressionTokenTime // A time value ExpressionTokenDateTime // A date-time value ExpressionTokenBoolean // [20] ExpressionTokenLiteral // ExpressionTokenDuration // duration = [ "duration" ] SQUOTE durationValue SQUOTE ExpressionTokenGuid // A 128-bit GUID ExpressionTokenAssignement // The '=' assignement for function arguments. ExpressionTokenGeographyPolygon // [25] ExpressionTokenGeometryPolygon // )
func (ExpressionTokenType) String ¶
func (e ExpressionTokenType) String() string
func (ExpressionTokenType) Value ¶
func (e ExpressionTokenType) Value() int
type GoDataAction ¶
type GoDataAction struct { XMLName xml.Name `xml:"Action"` Name string `xml:"Name,attr"` IsBound string `xml:"IsBound,attr,omitempty"` EntitySetPath string `xml:"EntitySetPath,attr,omitempty"` Parameters []*GoDataParameter ReturnType *GoDataReturnType }
type GoDataActionImport ¶
type GoDataAnnotation ¶
type GoDataAnnotations ¶
type GoDataAnnotations struct { XMLName xml.Name `xml:"Annotations"` Target string `xml:"Target,attr"` Qualifier string `xml:"Qualifier,attr,omitempty"` Annotations []*GoDataAnnotation }
type GoDataApplyQuery ¶
type GoDataApplyQuery string
func ParseApplyString ¶
func ParseApplyString(apply string) (*GoDataApplyQuery, error)
type GoDataComplexType ¶
type GoDataCountQuery ¶
type GoDataCountQuery bool
func ParseCountString ¶
func ParseCountString(count string) (*GoDataCountQuery, error)
type GoDataEntityContainer ¶
type GoDataEntityContainer struct { XMLName xml.Name `xml:"EntityContainer"` Name string `xml:"Name,attr"` Extends string `xml:"Extends,attr,omitempty"` EntitySets []*GoDataEntitySet Singletons []*GoDataSingleton ActionImports []*GoDataActionImport FunctionImports []*GoDataFunctionImport }
type GoDataEntitySet ¶
type GoDataEntityType ¶
type GoDataEntityType struct { XMLName xml.Name `xml:"EntityType"` Name string `xml:"Name,attr"` BaseType string `xml:"BaseType,attr,omitempty"` Abstract string `xml:"Abstract,attr,omitempty"` OpenType string `xml:"OpenType,attr,omitempty"` HasStream string `xml:"HasStream,attr,omitempty"` Key *GoDataKey Properties []*GoDataProperty }
type GoDataEnumType ¶
type GoDataError ¶
func BadRequestError ¶
func BadRequestError(message string) *GoDataError
func GoneError ¶
func GoneError(message string) *GoDataError
func InternalServerError ¶
func InternalServerError(message string) *GoDataError
func MethodNotAllowedError ¶
func MethodNotAllowedError(message string) *GoDataError
func NotFoundError ¶
func NotFoundError(message string) *GoDataError
func NotImplementedError ¶
func NotImplementedError(message string) *GoDataError
func PreconditionFailedError ¶
func PreconditionFailedError(message string) *GoDataError
func (*GoDataError) Error ¶
func (err *GoDataError) Error() string
func (*GoDataError) SetCause ¶
func (err *GoDataError) SetCause(e error) *GoDataError
func (*GoDataError) Unwrap ¶
func (err *GoDataError) Unwrap() error
type GoDataExpandQuery ¶
type GoDataExpandQuery struct {
ExpandItems []*ExpandItem
}
func ParseExpandString ¶
func ParseExpandString(expand string) (*GoDataExpandQuery, error)
type GoDataExpression ¶
type GoDataExpression struct { Tree *ParseNode // The raw string representing an expression RawValue string }
GoDataExpression encapsulates the tree representation of an expression as defined in the OData ABNF grammar.
type GoDataFilterQuery ¶
Stores a parsed version of the filter query string. Can be used by providers to apply the filter based on their own implementation. The filter is stored as a parse tree that can be traversed.
func ParseFilterString ¶
func ParseFilterString(filter string) (*GoDataFilterQuery, error)
ParseFilterString converts an input string from the $filter part of the URL into a parse tree that can be used by providers to create a response.
type GoDataFormatQuery ¶
type GoDataFormatQuery struct { }
type GoDataFunction ¶
type GoDataFunction struct { XMLName xml.Name `xml:"Function"` Name string `xml:"Name,attr"` IsBound string `xml:"IsBound,attr,omitempty"` IsComposable string `xml:"IsComposable,attr,omitempty"` EntitySetPath string `xml:"EntitySetPath,attr,omitempty"` Parameters []*GoDataParameter ReturnType *GoDataReturnType }
type GoDataFunctionImport ¶
type GoDataIdentifier ¶
func ParseIdentifiers ¶
func ParseIdentifiers(segment string) *GoDataIdentifier
func (*GoDataIdentifier) Get ¶
func (id *GoDataIdentifier) Get() string
Return the first key in the map. This is how you should get the identifier for single values, e.g. when the path is Employee(1), etc.
func (*GoDataIdentifier) GetKey ¶
func (id *GoDataIdentifier) GetKey(key string) (string, bool)
Return a specific value for a specific key.
func (*GoDataIdentifier) HasMultiple ¶
func (id *GoDataIdentifier) HasMultiple() bool
Check if this identifier has more than one key/value pair.
type GoDataInclude ¶
type GoDataInlineCountQuery ¶
type GoDataInlineCountQuery string
func ParseInlineCountString ¶
func ParseInlineCountString(inlinecount string) (*GoDataInlineCountQuery, error)
type GoDataKey ¶
type GoDataKey struct { XMLName xml.Name `xml:"Key"` PropertyRef *GoDataPropertyRef }
type GoDataMember ¶
type GoDataMetadata ¶
type GoDataMetadata struct { XMLName xml.Name `xml:"edmx:Edmx"` XMLNamespace string `xml:"xmlns:edmx,attr"` Version string `xml:"Version,attr"` DataServices *GoDataServices References []*GoDataReference }
func (*GoDataMetadata) Bytes ¶
func (t *GoDataMetadata) Bytes() ([]byte, error)
func (*GoDataMetadata) String ¶
func (t *GoDataMetadata) String() string
type GoDataNavigationProperty ¶
type GoDataNavigationProperty struct {}
type GoDataNavigationPropertyBinding ¶
type GoDataNavigationPropertyBinding struct {}
type GoDataOnDelete ¶
type GoDataOrderByQuery ¶
type GoDataOrderByQuery struct { OrderByItems []*OrderByItem // The raw orderby string RawValue string }
func ParseOrderByString ¶
func ParseOrderByString(orderby string) (*GoDataOrderByQuery, error)
type GoDataParameter ¶
type GoDataParameter struct { XMLName xml.Name `xml:"Parameter"` Name string `xml:"Name,attr"` Type string `xml:"Type,attr"` Nullable string `xml:"Nullable,attr,omitempty"` MaxLength int `xml:"MaxLength,attr,omitempty"` Precision int `xml:"Precision,attr,omitempty"` Scale int `xml:"Scale,attr,omitempty"` SRID string `xml:"SRID,attr,omitempty"` }
type GoDataProperty ¶
type GoDataProperty struct { XMLName xml.Name `xml:"Property"` Name string `xml:"Name,attr"` Type string `xml:"Type,attr"` Nullable string `xml:"Nullable,attr,omitempty"` MaxLength int `xml:"MaxLength,attr,omitempty"` Precision int `xml:"Precision,attr,omitempty"` Scale int `xml:"Scale,attr,omitempty"` Unicode string `xml:"Unicode,attr,omitempty"` SRID string `xml:"SRID,attr,omitempty"` DefaultValue string `xml:"DefaultValue,attr,omitempty"` }
type GoDataPropertyRef ¶
type GoDataProvider ¶
type GoDataProvider interface { // Request a single entity from the provider. Should return a response field // that contains the value mapping properties to values for the entity. GetEntity(*GoDataRequest) (*GoDataResponseField, error) // Request a collection of entities from the provider. Should return a // response field that contains the value of a slice of every entity in the // collection filtered by the request query parameters. GetEntityCollection(*GoDataRequest) (*GoDataResponseField, error) // Request the number of entities in a collection, disregarding any filter // query parameters. GetCount(*GoDataRequest) (int, error) // Get the object model representation from the provider. GetMetadata() *GoDataMetadata }
The basic interface for a GoData provider. All providers must implement these functions.
type GoDataQuery ¶
type GoDataQuery struct { Filter *GoDataFilterQuery At *GoDataFilterQuery Apply *GoDataApplyQuery Expand *GoDataExpandQuery Select *GoDataSelectQuery OrderBy *GoDataOrderByQuery Top *GoDataTopQuery Skip *GoDataSkipQuery Count *GoDataCountQuery InlineCount *GoDataInlineCountQuery Search *GoDataSearchQuery Format *GoDataFormatQuery }
func ParseUrlQuery ¶
func ParseUrlQuery(query url.Values, lenient bool) (*GoDataQuery, error)
type GoDataReference ¶
type GoDataReference struct { XMLName xml.Name `xml:"edmx:Reference"` Uri string `xml:"Uri,attr"` Includes []*GoDataInclude IncludeAnnotations []*GoDataIncludeAnnotations }
type GoDataReferentialConstraint ¶
type GoDataReferentialConstraint struct { XMLName xml.Name `xml:"ReferentialConstraint"` Property string `xml:"Property,attr"` ReferencedProperty string `xml:"ReferencedProperty,attr"` OnDelete *GoDataOnDelete `xml:"OnDelete,omitempty"` }
type GoDataRequest ¶
type GoDataRequest struct { FirstSegment *GoDataSegment LastSegment *GoDataSegment Query *GoDataQuery RequestKind int }
func ParseRequest ¶
Parse a request from the HTTP server and format it into a GoDaataRequest type to be passed to a provider to produce a result.
type GoDataResponse ¶
type GoDataResponse struct {
Fields map[string]*GoDataResponseField
}
A response is a dictionary of keys to their corresponding fields. This will be converted into a JSON dictionary in the response to the web client.
func (*GoDataResponse) Json ¶
func (r *GoDataResponse) Json() ([]byte, error)
Serialize the result as JSON for sending to the client. If an error occurs during the serialization, it will be returned.
type GoDataResponseField ¶
type GoDataResponseField struct {
Value interface{}
}
A response that is a primitive JSON type or a list or a dictionary. When writing to JSON, it is automatically mapped from the Go type to a suitable JSON data type. Any type can be used, but if the data type is not supported for serialization, then an error is thrown.
func (*GoDataResponseField) Json ¶
func (f *GoDataResponseField) Json() ([]byte, error)
Convert the response field to a JSON serialized form. If the type is not string, []byte, int, float64, map[string]*GoDataResponseField, or []*GoDataResponseField, then an error will be thrown.
type GoDataReturnType ¶
type GoDataReturnType struct { XMLName xml.Name `xml:"ReturnType"` Name string `xml:"Name,attr"` Type string `xml:"Type,attr"` Nullable string `xml:"Nullable,attr,omitempty"` MaxLength int `xml:"MaxLength,attr,omitempty"` Precision int `xml:"Precision,attr,omitempty"` Scale int `xml:"Scale,attr,omitempty"` SRID string `xml:"SRID,attr,omitempty"` }
type GoDataSchema ¶
type GoDataSchema struct { XMLName xml.Name `xml:"Schema"` Namespace string `xml:"Namespace,attr"` Alias string `xml:"Alias,attr,omitempty"` Actions []*GoDataAction Annotations []*GoDataAnnotations Annotation []*GoDataAnnotation ComplexTypes []*GoDataComplexType EntityContainers []*GoDataEntityContainer EntityTypes []*GoDataEntityType EnumTypes []*GoDataEnumType Functions []*GoDataFunction Terms []*GoDataTerm TypeDefinitions []*GoDataTypeDefinition }
type GoDataSearchQuery ¶
func ParseSearchString ¶
func ParseSearchString(filter string) (*GoDataSearchQuery, error)
Convert an input string from the $filter part of the URL into a parse tree that can be used by providers to create a response.
type GoDataSegment ¶
type GoDataSegment struct { // The raw segment parsed from the URI RawValue string // The kind of resource being pointed at by this segment SemanticType SemanticType // A pointer to the metadata type this object represents, as defined by a // particular service SemanticReference interface{} // The name of the entity, type, collection, etc. Name string // map[string]string of identifiers passed to this segment. If the identifier // is not key/value pair(s), then all values will be nil. If there is no // identifier, it will be nil. Identifier *GoDataIdentifier // The next segment in the path. Next *GoDataSegment // The previous segment in the path. Prev *GoDataSegment }
Represents a segment (slash-separated) part of the URI path. Each segment has a link to the next segment (the last segment precedes nil).
type GoDataSelectQuery ¶
type GoDataSelectQuery struct { SelectItems []*SelectItem // The raw select string RawValue string }
func ParseSelectString ¶
func ParseSelectString(sel string) (*GoDataSelectQuery, error)
type GoDataService ¶
type GoDataService struct { // The base url for the service. Navigating to this URL will display the // service document. BaseUrl *url.URL // The provider for this service that is serving the data to the OData API. Provider GoDataProvider // Metadata cache taken from the provider. Metadata *GoDataMetadata // A mapping from schema names to schema references SchemaLookup map[string]*GoDataSchema // A bottom-up mapping from entity type names to schema namespaces to // the entity type reference EntityTypeLookup map[string]map[string]*GoDataEntityType // A bottom-up mapping from entity container names to schema namespaces to // the entity container reference EntityContainerLookup map[string]map[string]*GoDataEntityContainer // A bottom-up mapping from entity set names to entity collection names to // schema namespaces to the entity set reference EntitySetLookup map[string]map[string]map[string]*GoDataEntitySet // A lookup for entity properties if an entity type is given, lookup // properties by name PropertyLookup map[*GoDataEntityType]map[string]*GoDataProperty // lookup navigational properties by name NavigationPropertyLookup map[*GoDataEntityType]map[string]*GoDataNavigationProperty }
A GoDataService will spawn an HTTP listener, which will connect GoData requests with a backend provider given to it.
func BuildService ¶
func BuildService(provider GoDataProvider, serviceUrl string) (*GoDataService, error)
Create a new service from a given provider. This step builds lookups for all parts of the data model, so constant time lookups can be performed. This step only happens once when the server starts up, so the overall cost is minimal. The given url will be treated as the base URL for all service requests, and used for building context URLs, etc.
func (*GoDataService) GoDataHTTPHandler ¶
func (service *GoDataService) GoDataHTTPHandler(w http.ResponseWriter, r *http.Request)
The default handler for parsing requests as GoDataRequests, passing them to a GoData provider, and then building a response.
func (*GoDataService) ListenAndServe ¶
func (service *GoDataService) ListenAndServe(addr string)
Start the service listening on the given address.
func (*GoDataService) LookupEntitySet ¶
func (service *GoDataService) LookupEntitySet(name string) (*GoDataEntitySet, error)
Lookup an entity set from the service metadata. Accepts a fully qualified name, e.g., ODataService.ContainerName.EntitySetName, ContainerName.EntitySetName or, if unambiguous, accepts a simple identifier, e.g., EntitySetName.
func (*GoDataService) LookupEntityType ¶
func (service *GoDataService) LookupEntityType(name string) (*GoDataEntityType, error)
Lookup an entity type from the service metadata. Accepts a fully qualified name, e.g., ODataService.EntityTypeName or, if unambiguous, accepts a simple identifier, e.g., EntityTypeName.
type GoDataServices ¶
type GoDataServices struct { XMLName xml.Name `xml:"edmx:DataServices"` Schemas []*GoDataSchema }
type GoDataSingleton ¶
type GoDataSkipQuery ¶
type GoDataSkipQuery int
func ParseSkipString ¶
func ParseSkipString(skip string) (*GoDataSkipQuery, error)
type GoDataTerm ¶
type GoDataTopQuery ¶
type GoDataTopQuery int
func ParseTopString ¶
func ParseTopString(top string) (*GoDataTopQuery, error)
type GoDataTypeDefinition ¶
type GoDataTypeDefinition struct { XMLName xml.Name `xml:"TypeDefinition"` Name string `xml:"Name,attr"` UnderlyingType string `xml:"UnderlyingTypeattr,omitempty"` Annotations []*GoDataAnnotation }
type ListExprToken ¶
type ListExprToken int
const ( // TokenTypeListExpr represents a parent node for a variadic listExpr. // "list" // "item1" // "item2" // ... TokenTypeListExpr ListExprToken = iota // TokenTypeArgCount is used to specify the number of arguments of a function or listExpr // This is used to handle variadic functions and listExpr. TokenTypeArgCount )
func (ListExprToken) String ¶
func (l ListExprToken) String() string
func (ListExprToken) Value ¶
func (l ListExprToken) Value() int
type Operator ¶
type Operator struct { Token string // Whether the operator is left/right/or not associative. // Determines how operators of the same precedence are grouped in the absence of parentheses. Association int // The number of operands this operator operates on Operands int // Rank of precedence. A higher value indicates higher precedence. Precedence int // Determine if the operands should be interpreted as a ListExpr or parenExpr according // to ODATA ABNF grammar. // This is only used when a listExpr has zero or one items. // When a listExpr has 2 or more items, there is no ambiguity between listExpr and parenExpr. // For example: // 2 + (3) ==> the right operand is a parenExpr. // City IN ('Seattle', 'Atlanta') ==> the right operand is unambiguously a listExpr. // City IN ('Seattle') ==> the right operand should be a listExpr. PreferListExpr bool }
func (*Operator) WithListExprPreference ¶
type OrderByItem ¶
type OrderByItem struct { Field *Token // The raw value of the orderby field or expression. Tree *GoDataExpression // The orderby expression parsed as a tree. Order string // Ascending or descending order. }
type Parser ¶
type Parser struct { // Map from string inputs to operator types Operators map[string]*Operator // Map from string inputs to function types Functions map[string]*Function LiteralToken TokenType }
func EmptyParser ¶
func EmptyParser() *Parser
func SearchParser ¶
func SearchParser() *Parser
func (*Parser) DefineFunction ¶
DefineFunction adds a function to the language params is the number of parameters this function accepts
func (*Parser) DefineOperator ¶
DefineOperator adds an operator to the language. Provide the token, the expected number of arguments, whether the operator is left, right, or not associative, and a precedence.
func (*Parser) InfixToPostfix ¶
InfixToPostfix parses the input string of tokens using the given definitions of operators and functions. Everything else is assumed to be a literal. Uses the Shunting-Yard algorithm.
Infix notation for variadic functions and operators: f ( a, b, c, d ) Postfix notation with wall notation: | a b c d f Postfix notation with count notation: a b c d 4 f
func (*Parser) PostfixToTree ¶
PostfixToTree converts a Postfix token queue to a parse tree
func (*Parser) WithLiteralToken ¶
type SearchTokenType ¶
type SearchTokenType int
const ( SearchTokenLiteral SearchTokenType = iota SearchTokenOpenParen SearchTokenCloseParen SearchTokenOp SearchTokenWhitespace )
func (SearchTokenType) Value ¶
func (s SearchTokenType) Value() int
type SelectItem ¶
type SelectItem struct {
Segments []*Token
}
type SemanticType ¶
type SemanticType int
const ( SemanticTypeUnknown SemanticType = iota SemanticTypeEntity SemanticTypeEntitySet SemanticTypeDerivedEntity SemanticTypeAction SemanticTypeFunction SemanticTypeProperty SemanticTypePropertyValue SemanticTypeRef SemanticTypeCount SemanticTypeMetadata )
type Token ¶
type Token struct { Value string Type TokenType // Holds information about the semantic meaning of this token taken from the // context of the GoDataService. SemanticType SemanticType SemanticReference interface{} }
type TokenHandler ¶
type TokenMatcher ¶
type TokenMatcher struct { Pattern string // The regular expression matching a ODATA query token, such as literal value, operator or function Re *regexp.Regexp // The compiled regex Token TokenType // The token identifier CaseInsensitive bool // Regex is case-insensitive Subst func(in string) string // A function that substitutes the raw input token with another representation. By default it is the identity. }
type TokenType ¶
type TokenType interface {
Value() int
}
TokenType is the interface that must be implemented by all token types.
type Tokenizer ¶
type Tokenizer struct { TokenMatchers []*TokenMatcher IgnoreMatchers []*TokenMatcher }
func ExpandTokenizer ¶
func ExpandTokenizer() *Tokenizer
func NewExpressionTokenizer ¶
func NewExpressionTokenizer() *Tokenizer
ExpressionTokenizer creates a tokenizer capable of tokenizing ODATA expressions. 4.01 Services MUST support case-insensitive operator names. See https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#_Toc31360955
func SearchTokenizer ¶
func SearchTokenizer() *Tokenizer
Create a tokenizer capable of tokenizing filter statements
func (*Tokenizer) AddWithSubstituteFunc ¶
type UnsupportedQueryParameterError ¶
type UnsupportedQueryParameterError struct {
Parameter string
}
func (*UnsupportedQueryParameterError) Error ¶
func (err *UnsupportedQueryParameterError) Error() string