rest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package rest provides a JSON REST API for server administration. All endpoints require a Bearer token (configured via bearer_token).

Routes:

POST   /api/v1/users                          — create user
GET    /api/v1/users/{username}               — get user info
PUT    /api/v1/users/{username}/password      — change password
DELETE /api/v1/users/{username}               — delete user
GET    /api/v1/users/{username}/sessions      — list user's active sessions
GET    /api/v1/users/{username}/roster        — get user's roster
GET    /api/v1/rooms                          — list MUC rooms
DELETE /api/v1/rooms/{room}                   — delete MUC room
POST   /api/v1/oauth/clients                  — create OAuth2 client
GET    /api/v1/oauth/clients                  — list OAuth2 clients
DELETE /api/v1/oauth/clients/{id}             — delete OAuth2 client
POST   /api/v1/oauth/token                    — issue OAuth2 access token
DELETE /api/v1/oauth/tokens/{token}           — revoke OAuth2 access token

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API exposes server administration endpoints over HTTP.

func New

func New(
	cfg Config,
	rep repository.Repository,
	resMng resourcemanager.Manager,
	hosts *host.Hosts,
	peppers *pepper.Keys,
	hk *hook.Hooks,
	logger kitlog.Logger,
) *API

New returns an initialized API instance.

func (*API) Register

func (a *API) Register(mux *http.ServeMux)

Register registers all REST routes on mux. Does nothing if BearerToken is empty.

type Config

type Config struct {
	// BearerToken is the static secret required in the Authorization header.
	// If empty, the API is disabled.
	BearerToken string `fig:"bearer_token"`
}

Config holds REST API configuration.

Jump to

Keyboard shortcuts

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