httpapi

package
v0.1.113 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 10 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 httpapi serves search.Search over HTTP for a host to mount: GET ?q=&kind=&limit=.

Index

Constants

View Source
const MaxLimit = 100

MaxLimit caps the per-kind limit a request may ask for.

Variables

View Source
var ErrInvalidKind = errors.New("invalid kind")

ErrInvalidKind is the error for a kind filter naming an unknown kind, or including and excluding one at once.

Functions

func AddOpenAPI

func AddOpenAPI(spec *rpc.OpenAPISpec, path string)

AddOpenAPI documents the handler mounted at path.

func ParseKinds

func ParseKinds(values []string) ([]search.Kind, error)

ParseKinds reads a kind filter: values repeated or comma-separated, `!` excluding. Only inclusions keep those kinds; only exclusions keep every other kind; none is nil (every kind).

Types

type API

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

func New

func New(options Options) (*API, error)

func (*API) Handler

func (a *API) Handler() http.HandlerFunc

Handler answers a search.Result. kind is repeatable or comma-separated; `!kind` excludes; none searches every kind. limit is per kind (default 20, at most MaxLimit).

type Options

type Options struct {
	Sources   func(ctx context.Context) ([]search.Source, error)
	Authorize func(ctx context.Context, kind search.Kind) error
}

Options configures New. Sources builds the sources of the request's caller (its error fails the request, so a host reports a source it cannot open with search.Failed instead); Authorize admits each kind, a refused kind being skipped with the reason rather than failing the request.

Jump to

Keyboard shortcuts

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