legacy

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 21 Imported by: ? 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 legacy serves etherpad-lite's HTTP API, /api/{version}/{function}, for clients written against it (Moodle, Nextcloud, WordPress plugins and the like). Calls are checked the way etherpad-lite checks them and then run by the REST API under /admin/api, so both behave the same.

Requests: GET or POST; parameters in the query string, a form body or a JSON body (body before query). Responses: {"code", "message", "data"}, where code 0 is ok, 1 a wrong parameter (HTTP 200), 2 an internal error (500), 3 no such function (404) and 4 no or wrong API key (401).

Index

Constants

View Source
const LatestVersion = "1.3.1"

LatestVersion is the newest API version (etherpad-lite 1.3.1).

Variables

This section is empty.

Functions

func APIKeyFile

func APIKeyFile(root string) string

APIKeyFile is where etherpad-lite and earlier etherpad-go releases kept the API key. A key found there is taken over into the admin UI's keys.

func ReadAPIKeyFile

func ReadAPIKeyFile(path string) (string, error)

ReadAPIKeyFile returns the key in path, or "" when there is no such file.

Types

type API

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

API serves the legacy HTTP API.

func New

func New(store *lib.InitStore, keys *tokens.Manager, bearer Authenticator) *API

New builds the API. Calls need a token (apikey, api_key or authorization parameter, or the Authorization header) that may do what the call does (scopes.go), or a bearer token accepted by bearer, as for /admin/api, which may do everything.

func (*API) Register

func (a *API) Register(app *fiber.App)

Register adds the routes: /api (current version), /api/{version}/{function}, and the REST styles (rest.go).

type Authenticator

type Authenticator func(token string) bool

Authenticator checks a bearer token when the API key is not used.

type FileResult

type FileResult int

FileResult is what ImportAPIKeyFile did.

const (
	// FileNone: no file, or nothing to do.
	FileNone FileResult = iota
	// FileStored: the file's key is now a token.
	FileStored
	// FileKnown: the file's key already was a token.
	FileKnown
	// FileIgnored: the file is there, but the one take-over is done.
	FileIgnored
)

func ImportAPIKeyFile

func ImportAPIKeyFile(keys *tokens.Manager, path string) (FileResult, error)

ImportAPIKeyFile takes over the key of an APIKEY.txt as a token named "APIKEY.txt", on the first start with tokens only: the database then remembers that it was done (for every instance of a cluster), and a file found later is ignored. A failure leaves it to the next start.

type Response

type Response struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    any    `json:"data"`
}

Response is the reply of every call.

Jump to

Keyboard shortcuts

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