httpapi

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: GPL-3.0 Imports: 19 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 httpapi exposes the service over loopback HTTP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DictionariesResponse

type DictionariesResponse struct {
	Directory    string        `json:"directory"`
	Dictionaries []mdict.Info  `json:"dictionaries"`
	Generated    time.Time     `json:"generated"`
	Elapsed      time.Duration `json:"-"`
}

DictionariesResponse lists the installed dictionaries.

type ErrorResponse

type ErrorResponse struct {
	Error   string `json:"error"`
	Message string `json:"message"`
	// Hint tells the user what to actually do about it.
	Hint string `json:"hint,omitempty"`
}

ErrorResponse is the uniform error shape the plugin understands.

type LookupRequest

type LookupRequest struct {
	Query string `json:"query"`
	// Dictionaries restricts the search; empty means every dictionary.
	Dictionaries []string `json:"dictionaries,omitempty"`
	// Mode is "exact" or "smart".
	Mode string `json:"mode,omitempty"`
	// Limit caps how many dictionaries answer.
	Limit int `json:"limit,omitempty"`
	// MaxExamples caps examples per sense.
	MaxExamples int  `json:"maxExamples,omitempty"`
	Debug       bool `json:"debug,omitempty"`
	// Format is "ir" (default), "bob", "plain", or "markdown". Presentation formats add
	// a rendered sibling field while preserving the canonical IR matches.
	Format string `json:"format,omitempty"`
	// IncludeExamples and IncludeExtras let the user trim what Bob displays.
	IncludeExamples *bool `json:"includeExamples,omitempty"`
	IncludeExtras   *bool `json:"includeExtras,omitempty"`
	// IncludeGrammar lets the user hide detailed grammatical qualifiers from presentation.
	IncludeGrammar *bool `json:"includeGrammar,omitempty"`
	// MultiRecordMode controls presentation only, in both the Bob card and
	// Plain/Markdown: "separate" selects one semantic record and offers sibling
	// navigation; "combined" renders every record with explicit boundaries.
	MultiRecordMode string `json:"multiRecordMode,omitempty"`
	// RecordOrdinal is one-based over the visible, deduplicated EntrySet.
	RecordOrdinal int `json:"recordOrdinal,omitempty"`
}

LookupRequest is the body of POST /v2/lookup.

type Server

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

Server routes HTTP requests to the service.

func New

func New(svc *service.Service, log *slog.Logger) *Server

New creates a server.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler builds the routed handler.

type StatusResponse

type StatusResponse struct {
	Service                string  `json:"service"`
	ServiceVersion         string  `json:"serviceVersion"`
	BuildCommit            string  `json:"buildCommit"`
	APIVersion             string  `json:"apiVersion"`
	Platform               string  `json:"platform"`
	Architecture           string  `json:"architecture"`
	DictionaryDirectory    string  `json:"dictionaryDirectory"`
	DictionaryCount        int     `json:"dictionaryCount"`
	HealthyDictionaryCount int     `json:"healthyDictionaryCount"`
	AudioAvailable         bool    `json:"audioAvailable"`
	SpeexAvailable         bool    `json:"speexAvailable"`
	SpeexDecoder           string  `json:"speexDecoder,omitempty"`
	UptimeSeconds          float64 `json:"uptimeSeconds"`
}

StatusResponse describes the running service.

Jump to

Keyboard shortcuts

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