Skip to main content
Go · HTTP · GORM

Query APIs without exposing SQL.

Parse a small HTTP query language, validate every field and literal against your model, then apply safe GORM scopes.

base := db.Where("tenant_id = ?", tenantID)

page, err := users.
From(base).
List(r.Context(), r.URL.Query())
if err != nil {
queryhttp.WriteError(w, err)
return
}

json.NewEncoder(w).Encode(page)

Schema first

Public names, Go fields, database columns, scalar types, and allowed operations are explicit.

SQL-safe by construction

Values stay bound parameters. Columns come from an immutable whitelist and are dialect-quoted by GORM.

Errors clients can use

Stable error codes, field and operator metadata, and byte-accurate source positions.

Bounded work

Limits cover page size, offsets, input bytes, AST nodes, expression depth, and relationship traversal.