Documentation
¶
Overview ¶
internal/api/handlers/component.go
Index ¶
- Constants
- Variables
- func CreateAgent(c *gin.Context)
- func CreateCollection(c *gin.Context)
- func CreateComponent(c *gin.Context)
- func CreateItem(collection models.Collection) gin.HandlerFunc
- func CreateOrUpdateSingleton(c *gin.Context)
- func CreateOrUpdateSingletonItem(c *gin.Context)
- func CreateUser(c *gin.Context)
- func DeleteAgent(c *gin.Context)
- func DeleteCollection(c *gin.Context)
- func DeleteComponent(c *gin.Context)
- func DeleteItem(ct models.Collection) gin.HandlerFunc
- func DeleteSingleton(c *gin.Context)
- func DeleteUser(c *gin.Context)
- func DynamicCollectionHandler(c *gin.Context)
- func GetAgent(c *gin.Context)
- func GetAgents(c *gin.Context)
- func GetAllUsers(c *gin.Context)
- func GetCollection(c *gin.Context)
- func GetCollections(c *gin.Context)
- func GetComponent(c *gin.Context)
- func GetComponents(c *gin.Context)
- func GetItemByID(ct models.Collection, id uint, level uint) gin.HandlerFunc
- func GetItems(collection models.Collection, level uint) gin.HandlerFunc
- func GetSingleItem(c *gin.Context)
- func GetSingleton(c *gin.Context)
- func GetSingletons(c *gin.Context)
- func GetUser(c *gin.Context)
- func GraphQLHandler(c *gin.Context)
- func HandleWebhook(c *gin.Context)
- func InitAsynqClient(client *asynq.Client)
- func Login(c *gin.Context)
- func Register(c *gin.Context)
- func UpdateAgent(c *gin.Context)
- func UpdateCollection(c *gin.Context)
- func UpdateComponent(c *gin.Context)
- func UpdateItem(collection models.Collection) gin.HandlerFunc
- func UpdateUser(c *gin.Context)
- type LoginAttemptGuard
Constants ¶
const DefaultRegistrationRole = "viewer"
DefaultRegistrationRole is the role given to self-registered accounts.
Variables ¶
var SchemaNotifier interface { Notify(ctx context.Context) error }
SchemaNotifier tells other API replicas that the schema changed. It is set at startup (see cmd/start.go); nil means single-replica mode.
Functions ¶
func CreateCollection ¶
CreateCollection handles creating a new collection.
func CreateComponent ¶
CreateComponentHandler creates a new component definition.
func CreateItem ¶
func CreateItem(collection models.Collection) gin.HandlerFunc
CreateItem handles nested creations
func CreateOrUpdateSingleton ¶
CreateOrUpdateSingleton handles the creation or updating of a single type.
func CreateOrUpdateSingletonItem ¶
CreateOrUpdateSingletonValue handles the creation or update of a single type content item.
func CreateUser ¶
CreateUser lets an admin create an account with any existing role.
func DeleteAgent ¶
DeleteAgent handles deleting an agent by its name.
func DeleteCollection ¶
DeleteCollectionByIDHandler handles deleting a collection by its ID.
func DeleteComponent ¶
DeleteComponentHandler deletes a component by name.
func DeleteItem ¶
func DeleteItem(ct models.Collection) gin.HandlerFunc
func DeleteSingleton ¶
DeleteSingleton handles deleting a single type by its name (optional).
func DynamicCollectionHandler ¶
DynamicCollectionHandler handles CRUD operations for dynamic collections.
func GetCollection ¶
func GetCollections ¶
GetCollections retrieves a list of collections with optional filtering, sorting, and pagination.
func GetComponent ¶
GetComponentHandler retrieves a component by name.
func GetComponents ¶
GetComponents lists all component definitions.
func GetItemByID ¶
func GetItemByID(ct models.Collection, id uint, level uint) gin.HandlerFunc
GetItemByID retrieves a single item by ID.
func GetItems ¶
func GetItems(collection models.Collection, level uint) gin.HandlerFunc
GetItems lists a collection's items with pagination, filtering and sorting.
Query parameters:
page, pageSize pagination (pageSize max 100) filters[<field>][<op>]=<value> op: $eq $ne $lt $lte $gt $gte $contains filters[<field>]=<value> shorthand for $eq sort=<field>[:asc|:desc],... multiple keys allowed
<field> is a collection attribute or one of id, created_at, updated_at.
func GetSingleItem ¶
GetSingleItem retrieves the content (single item) for a given single type name.
func GetSingleton ¶
GetSingleton retrieves a single type by its name.
func GetSingletons ¶
GetSingletons lists all singleton definitions.
func GraphQLHandler ¶
GraphQLHandler executes a GraphQL request. The caller's role is passed to resolvers through the context so that queries and mutations enforce the same permissions as the REST API.
func HandleWebhook ¶
HandleWebhook is the Gin handler for incoming agent webhook requests.
func InitAsynqClient ¶
InitAsynqClient initializes the trigger package with a shared Asynq client. This function should be called once when your server starts.
func Register ¶
Register creates a new account through the public endpoint.
The caller can never choose its own role: the very first account created on an empty instance becomes "admin" (bootstrap), every later account gets the least-privileged DefaultRegistrationRole. Admins promote users through PUT /admin/users/:id.
func UpdateCollection ¶
UpdateCollection handles updating an existing collection.
func UpdateComponent ¶
UpdateComponentHandler updates an existing component definition.
func UpdateItem ¶
func UpdateItem(collection models.Collection) gin.HandlerFunc
UpdateItem now handles nested creations and uses the c.Set response pattern.
func UpdateUser ¶
UpdateUser lets an admin change a user's username, email, password or role. Unknown fields are rejected so that arbitrary columns cannot be written.
Types ¶
type LoginAttemptGuard ¶
LoginAttemptGuard limits failed logins per (username, client IP) within a window. Keying on both stops password guessing against an account without letting anyone lock a user out from another address.
var LoginGuard *LoginAttemptGuard
LoginGuard is set at startup; nil disables the check.