handlers

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 30 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

internal/api/handlers/component.go

Index

Constants

View Source
const DefaultRegistrationRole = "viewer"

DefaultRegistrationRole is the role given to self-registered accounts.

Variables

View Source
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 CreateAgent

func CreateAgent(c *gin.Context)

CreateAgent handles creating a new agent.

func CreateCollection

func CreateCollection(c *gin.Context)

CreateCollection handles creating a new collection.

func CreateComponent

func CreateComponent(c *gin.Context)

CreateComponentHandler creates a new component definition.

func CreateItem

func CreateItem(collection models.Collection) gin.HandlerFunc

CreateItem handles nested creations

func CreateOrUpdateSingleton

func CreateOrUpdateSingleton(c *gin.Context)

CreateOrUpdateSingleton handles the creation or updating of a single type.

func CreateOrUpdateSingletonItem

func CreateOrUpdateSingletonItem(c *gin.Context)

CreateOrUpdateSingletonValue handles the creation or update of a single type content item.

func CreateUser

func CreateUser(c *gin.Context)

CreateUser lets an admin create an account with any existing role.

func DeleteAgent

func DeleteAgent(c *gin.Context)

DeleteAgent handles deleting an agent by its name.

func DeleteCollection

func DeleteCollection(c *gin.Context)

DeleteCollectionByIDHandler handles deleting a collection by its ID.

func DeleteComponent

func DeleteComponent(c *gin.Context)

DeleteComponentHandler deletes a component by name.

func DeleteItem

func DeleteItem(ct models.Collection) gin.HandlerFunc

func DeleteSingleton

func DeleteSingleton(c *gin.Context)

DeleteSingleton handles deleting a single type by its name (optional).

func DeleteUser

func DeleteUser(c *gin.Context)

DeleteUser handles deleting a user.

func DynamicCollectionHandler

func DynamicCollectionHandler(c *gin.Context)

DynamicCollectionHandler handles CRUD operations for dynamic collections.

func GetAgent

func GetAgent(c *gin.Context)

func GetAgents

func GetAgents(c *gin.Context)

GetAgents retrieves a list of agents with optional filtering and pagination.

func GetAllUsers

func GetAllUsers(c *gin.Context)

GetAllUsers handles fetching all users.

func GetCollection

func GetCollection(c *gin.Context)

func GetCollections

func GetCollections(c *gin.Context)

GetCollections retrieves a list of collections with optional filtering, sorting, and pagination.

func GetComponent

func GetComponent(c *gin.Context)

GetComponentHandler retrieves a component by name.

func GetComponents

func GetComponents(c *gin.Context)

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

func GetSingleItem(c *gin.Context)

GetSingleItem retrieves the content (single item) for a given single type name.

func GetSingleton

func GetSingleton(c *gin.Context)

GetSingleton retrieves a single type by its name.

func GetSingletons

func GetSingletons(c *gin.Context)

GetSingletons lists all singleton definitions.

func GetUser

func GetUser(c *gin.Context)

GetUser handles fetching a single user by ID.

func GraphQLHandler

func GraphQLHandler(c *gin.Context)

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

func HandleWebhook(c *gin.Context)

HandleWebhook is the Gin handler for incoming agent webhook requests.

func InitAsynqClient

func InitAsynqClient(client *asynq.Client)

InitAsynqClient initializes the trigger package with a shared Asynq client. This function should be called once when your server starts.

func Login

func Login(c *gin.Context)

func Register

func Register(c *gin.Context)

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 UpdateAgent

func UpdateAgent(c *gin.Context)

UpdateAgent handles updating an existing agent.

func UpdateCollection

func UpdateCollection(c *gin.Context)

UpdateCollection handles updating an existing collection.

func UpdateComponent

func UpdateComponent(c *gin.Context)

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

func UpdateUser(c *gin.Context)

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

type LoginAttemptGuard struct {
	Counter     ratelimit.Counter
	MaxFailures int
	Window      time.Duration
}

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.

Jump to

Keyboard shortcuts

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