admin

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

internal/admin/handler.go

internal/admin/info.go

internal/admin/schema.go

Index

Constants

View Source
const SchemaVersion = "1"

SchemaVersion is bumped only on breaking changes to admin/JSON responses.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound indicates that a query parsed successfully but no matching share exists (or the share is revoked/expired). Handlers map this to 404. Parse failures, by contrast, should surface as 400.

Functions

func NewHandler

func NewHandler(c Core) http.Handler

NewHandler returns the admin HTTP handler.

func ParseInfoQuery added in v0.2.0

func ParseInfoQuery(raw string) (token, id string, err error)

ParseInfoQuery normalizes one of {full URL, path /t/<tok>/<name>, bare token, bare id} into either a token (26-char base32) or an id (8-char base32). Exactly one of the returned values is populated on success.

Types

type Core

type Core interface {
	Secret() string
	Share(ShareRequest) (SharePayload, error)
	Revoke(id string) error
	Reshare(id string) (SharePayload, error)
	Info(query string) (InfoPayload, error)
	List() ListResponse
	Status() StatusResponse
	Stop()
}

Core is the subset of the daemon that the admin handler needs.

type IDRequest

type IDRequest struct {
	ID string `json:"id"`
}

type InfoPayload added in v0.2.0

type InfoPayload struct {
	SharePayload
	SrcPath   string    `json:"src_path"`
	CreatedAt time.Time `json:"created_at"`
}

InfoPayload augments SharePayload with src_path and created_at, returned by GET /info. Token is intentionally included (via embedded SharePayload) because /info is on the Bearer-auth-gated admin API, same as /share and /list; callers already have the secret and can obtain the token via /list anyway.

type ListEntry

type ListEntry struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	URL       string    `json:"url"`
	ExpiresAt time.Time `json:"expires_at"`
	Remaining int64     `json:"remaining_seconds"`
}

type ListResponse

type ListResponse struct {
	SchemaVersion string      `json:"schema_version"`
	Shares        []ListEntry `json:"shares"`
}

type OKResponse

type OKResponse struct {
	SchemaVersion string `json:"schema_version"`
	OK            bool   `json:"ok"`
}

type SharePayload

type SharePayload struct {
	SchemaVersion string    `json:"schema_version"`
	ID            string    `json:"id"`
	Token         string    `json:"token"`
	URL           string    `json:"url"`
	ExpiresAt     time.Time `json:"expires_at"`
}

type ShareRequest

type ShareRequest struct {
	SrcPath     string `json:"src_path"`
	DisplayName string `json:"display_name,omitempty"`
	TTLSeconds  int64  `json:"ttl_seconds,omitempty"`
}

type StatusResponse

type StatusResponse struct {
	SchemaVersion string `json:"schema_version"`
	PID           int    `json:"pid"`
	Uptime        int64  `json:"uptime_seconds"`
	Port          int    `json:"port"`
	ActiveCount   int    `json:"active_count"`
	Version       string `json:"version"`
}

Jump to

Keyboard shortcuts

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