Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutes ¶
func RegisterRoutes(mux *http.ServeMux, state StateManager)
Types ¶
type ResourceDefinition ¶
type ResourceDefinition struct {
ID string `json:"id,omitempty"`
Path string `json:"path,omitempty"`
Singular string `json:"singular"`
Plural string `json:"plural"`
Description string `json:"description,omitempty"`
Examples map[string]any `json:"examples,omitempty"`
Schema openapi.Schema `json:"schema"`
// Enums declares the allowed string values for enum-constrained fields.
// The map is keyed by field (property) name and holds the list of allowed
// values. Only string fields may be constrained. Absent fields are
// unconstrained.
Enums map[string][]string `json:"enums,omitempty"`
// FileFields lists the names of properties that hold binary file contents
// (marked with x-aepbase-file-field: true and type: binary in the schema).
// File fields are an aepbase-specific, non-AEP extension and are only
// honored when file-field support is enabled on the server.
FileFields []string `json:"file_fields,omitempty"`
Parents []string `json:"parents,omitempty"`
Singleton bool `json:"singleton,omitempty"`
UserSettableId bool `json:"user_settable_create,omitempty"`
CreateTime string `json:"create_time,omitempty"`
UpdateTime string `json:"update_time,omitempty"`
}
func (ResourceDefinition) MarshalJSON ¶
func (d ResourceDefinition) MarshalJSON() ([]byte, error)
MarshalJSON re-injects x-aepbase-file-field: true on each property listed in FileFields. openapi.Schema drops unknown extensions on round-trip, so without this the marker is missing from every meta-handler response.
type StateManager ¶
type StateManager interface {
GetDB() *sql.DB
AddResource(def ResourceDefinition) error
RemoveResource(singular string) error
UpdateResourceSchema(def ResourceDefinition, oldDef ResourceDefinition) error
// HasResource reports whether a resource with the given singular name
// exists (including built-in resources like "user" that are not stored
// in the _aep_resource_definitions table).
HasResource(singular string) bool
}
StateManager is the interface that the central state must implement. This avoids a circular import between meta and aepbase.
Click to show internal directories.
Click to hide internal directories.