Help us shape the future of Go! Take the 2026 Go Developer Survey

api

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package api is brevis-sql-api as a library: the command, with the hooks a binary of your own registers.

The published binary is ten lines around Main with no hooks, and so is yours with some -- sql/example is one:

hooks := api.NewHooks()
hooks.MustRegisterBefore("check_window", checkWindow)
hooks.MustRegisterAfter("to_series", toSeries)
api.Main(hooks)

A BINARY OF ITS OWN and not a `brevis-sql` subcommand, for the weight `sql-weight.sh` guards: `brevis-sql` runs as a step in every pipeline that builds a model, and it must not carry what an HTTP API needs and a build never uses. Same module, so the connections, the dialects and the read-only guard are the ones the build and `serve` already trust.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(hooks *Hooks)

Main is the brevis-sql-api command, serving with hooks. It exits.

func Refuse

func Refuse(msg string) error

Refuse is how a before hook answers 400, with msg as written.

Types

type After

type After = api.After

After returns what becomes the answer's `data`. Its output is cached, so it must be a function of its Result.

type Before

type Before = api.Before

Before runs before the parameters are read: nil goes on, Refuse answers 400, any other error answers 500 with the text kept for the audit line.

type Hooks

type Hooks = api.Hooks

Hooks is what a binary knows how to run, named by an endpoint's `hook:`.

func NewHooks

func NewHooks() *Hooks

NewHooks is an empty registry; the published binary is Main(NewHooks()).

type Request

type Request = api.Request

Request is what a before hook sees of one call; only Query is kept.

type Result

type Result = api.Result

Result is what an after hook sees: the rows, already cut by max_rows.

Jump to

Keyboard shortcuts

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