odata

package
v0.0.0-...-e043755 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyExpand

func ApplyExpand(entities interface{}, expand string, handler ExpandHandler) interface{}

func ApplySelect

func ApplySelect(entities interface{}, selectQuery string) interface{}

func ApplySkipTop

func ApplySkipTop(entities interface{}, skip, top string) interface{}

func CreateODataResponse

func CreateODataResponse(w http.ResponseWriter, entitySet string, entities interface{})

Helper function to create OData response for multiple entities

func CreateODataResponseSingle

func CreateODataResponseSingle(w http.ResponseWriter, entitySet string, entity interface{})

Helper function to create OData response for a single entity

func EntityToMap

func EntityToMap(entity interface{}, expand string) map[string]interface{}

func GenerateMetadata

func GenerateMetadata() string

func ParseSelect

func ParseSelect(selectQuery string) string

func RegisterEntity

func RegisterEntity(entity Entity, handler EntityHandler)

func RegisterEntityRelationship

func RegisterEntityRelationship(entityName, relationshipName, targetEntityName, relationType string)

func RegisterRoutes

func RegisterRoutes(router *chi.Mux)

Types

type DefaultExpandHandler

type DefaultExpandHandler struct{}

DefaultExpandHandler is a fallback handler that does nothing

func (DefaultExpandHandler) ExpandEntity

func (h DefaultExpandHandler) ExpandEntity(entity OrderedFields, relationshipName string, subQuery string) interface{}

type Entity

type Entity interface {
	EntityName() string
	GetRelationships() map[string]string
}

type EntityHandler

type EntityHandler struct {
	GetEntityHandler     func(http.ResponseWriter, *http.Request)
	GetEntityByIDHandler func(http.ResponseWriter, *http.Request, string)
	ExpandHandler
}

func GetEntityHandler

func GetEntityHandler(entityName string) (EntityHandler, bool)

type ExpandHandler

type ExpandHandler interface {
	ExpandEntity(entity OrderedFields, relationshipName string, subQuery string) interface{}
}

type OrderedFields

type OrderedFields struct {
	EntityName string
	Fields     []struct {
		Key   string
		Value interface{}
	}
}

OrderedFields represents a slice of key-value pairs to maintain field order

func ApplyExpandSingle

func ApplyExpandSingle(entity interface{}, expand string, handler ExpandHandler) OrderedFields

func ApplySelectSingle

func ApplySelectSingle(entity OrderedFields, selectedFields []string) OrderedFields

func EntityToOrderedFields

func EntityToOrderedFields(entity interface{}, expand string) OrderedFields

func (OrderedFields) MarshalJSON

func (of OrderedFields) MarshalJSON() ([]byte, error)

type RelationshipInfo

type RelationshipInfo struct {
	TargetEntity string
	Type         string // "one-to-one", "one-to-many", etc.
}

Jump to

Keyboard shortcuts

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