api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package api is WittyCD's own HTTP API and SDUI source (module API 5): finding which album an audio CD is. WittyMediaServer passes an administrator's request for /api/modules/wittycd/... here once it has checked who is asking and that they may see the disc (integration.json).

The lookups themselves are the server's, through its host API: the process that reads disc images never has a network, so the server asks MusicBrainz with the disc's table of contents and fetches the cover, as its library scan does. This is the route a person (or a TV's page) reaches, and what it shows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Guard

func Guard(token string, next http.Handler) http.Handler

Guard lets in only whoever was told the start's secret, which is the server: a port on this machine can be reached by anything else running on it.

func Items

func Items(h Host, req sdui.ItemsRequest) (sdui.ItemsAnswer, error)

Items answers the server's sdui.items call for WittyCD's source.

func Routes

func Routes(mux *http.ServeMux, h Host)

Routes adds WittyCD's routes, written without the /http prefix the server passes them under.

Types

type Dual

type Dual struct {
	Helper wittymodule.Handler
	// contains filtered or unexported fields
}

Dual is one process answering as either of the two things a server starts wittycd-module as:

  • a helper with one open image, as it always was (Helper), started for each disc played, and never given a network;
  • WittyCD's service (module API 5): the server's first call is then service.MethodStart, with where its host API is. It listens on this machine only, with a secret of its own, for the routes the server passes on, and answers the SDUI and lifecycle calls.

wittymodule/service.Main runs a service only, and answers every other call with "unknown-method", so it can't also be the helper a server asks about one image: this is that part of it, with the same guard (a WittyModule gap: a service with helper calls of its own).

func (*Dual) Handle

func (d *Dual) Handle(method string, params json.RawMessage) (any, []byte, error)

Handle is the helper protocol's handler, for wittymodule.Serve.

func (*Dual) Mux

func (d *Dual) Mux() http.Handler

Mux is the service's handler: WittyCD's routes under /http, as the server passes them.

type Host

type Host interface {
	Do(ctx context.Context, on host.On, method, path string, body, out any) error
}

Host is the part of the host API this uses (host.Client).

Jump to

Keyboard shortcuts

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