Documentation
¶
Overview ¶
Package httpapi serves search.Search over HTTP for a host to mount: GET ?q=&kind=&limit=.
Index ¶
Constants ¶
const MaxLimit = 100
MaxLimit caps the per-kind limit a request may ask for.
Variables ¶
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.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
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.