sharing

package
v0.260716.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MPL-2.0 Imports: 10 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

Package apitoken implements CRUD HTTP endpoints for shared API tokens. It is intentionally free of any internal/server import — all error responses are written inline so the package has no circular dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRoutes

func RegisterRoutes(group *swagger.RouteGroup, h *Handler)

RegisterRoutes wires all token management endpoints onto the given group.

Types

type APITokenInfo

type APITokenInfo struct {
	TokenID     string     `json:"token_id"`
	UserID      string     `json:"user_id"`
	DisplayName string     `json:"display_name"`
	Enabled     bool       `json:"enabled"`
	LastUsedAt  *time.Time `json:"last_used_at,omitempty"`
	CreatedAt   time.Time  `json:"created_at"`
	CreatedBy   string     `json:"created_by,omitempty"`
}

APITokenInfo represents token metadata (without the raw token string).

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handles API-token HTTP requests.

func NewHandler

func NewHandler(store *db.APITokenStore) *Handler

NewHandler creates a Handler backed by the given store.

func (*Handler) Create

func (h *Handler) Create(c *gin.Context)

Create handles POST /tokens — creates a new shared API token.

func (*Handler) Delete

func (h *Handler) Delete(c *gin.Context)

Delete handles DELETE /tokens/:token_id.

func (*Handler) Disable

func (h *Handler) Disable(c *gin.Context)

Disable handles PUT /tokens/:token_id/disable.

func (*Handler) Enable

func (h *Handler) Enable(c *gin.Context)

Enable handles PUT /tokens/:token_id/enable.

func (*Handler) Get

func (h *Handler) Get(c *gin.Context)

Get handles GET /tokens/:token_id.

func (*Handler) List

func (h *Handler) List(c *gin.Context)

List handles GET /tokens — lists tokens with optional filters.

func (*Handler) Regenerate

func (h *Handler) Regenerate(c *gin.Context)

Regenerate handles POST /tokens/:token_id/regenerate — keeps the same token_id but issues a new token string.

type TokenCreateRequest

type TokenCreateRequest struct {
	DisplayName string `json:"display_name" binding:"required"`
}

TokenCreateRequest is the request body for creating a new API token.

type TokenCreateResponse

type TokenCreateResponse struct {
	Token       string    `json:"token"`
	TokenID     string    `json:"token_id"`
	UserID      string    `json:"user_id"`
	DisplayName string    `json:"display_name"`
	CreatedAt   time.Time `json:"created_at"`
}

TokenCreateResponse is returned after a token is created or regenerated.

type TokenListQuery added in v0.260716.1

type TokenListQuery struct {
	UserID  string `form:"user_id" json:"user_id,omitempty"`
	Enabled *bool  `form:"enabled" json:"enabled,omitempty"`
	Limit   int    `form:"limit" json:"limit,omitempty"`
	Offset  int    `form:"offset" json:"offset,omitempty"`
}

TokenListQuery describes the optional filters accepted by GET /tokens.

type TokenListResponse

type TokenListResponse struct {
	Tokens []APITokenInfo `json:"tokens"`
	Total  int64          `json:"total"`
}

TokenListResponse is the response for listing tokens.

Jump to

Keyboard shortcuts

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