Skip to main content

postrust_server/
lib.rs

1//! Postrust Server library.
2//!
3//! This crate provides the HTTP server implementation for Postrust.
4//!
5//! ## Features
6//!
7//! - `graphql` - Serves the GraphQL API at `/v1/graphql`, with Hasura's
8//!   contract, subscriptions and Apollo Federation.
9//! - `admin-ui` - Implies `graphql`, and enables the admin UI with OpenAPI documentation,
10//!   Swagger UI, Scalar, and GraphQL Playground at `/admin`.
11//! - `otel` - OpenTelemetry: traces and metrics exported over OTLP, and the
12//!   metrics as Prometheus text at `/metrics` on the admin port. Inactive
13//!   until configured; see [`otel`] and docs/observability.md.
14
15#![warn(missing_docs)]
16// Every fallible function in this crate returns `postrust_core::Error`, which
17// is a wide enum by design: a PostgREST error carries its code, message,
18// details and hint. Boxing it to satisfy the lint would put an allocation on
19// the error path of every request to save a return slot on the success path.
20// `postrust-core` takes the same position at its own crate root; this was
21// being restated a dozen times a file instead.
22#![allow(clippy::result_large_err)]
23
24pub mod app;
25pub mod build;
26pub mod custom;
27mod error;
28mod jwks;
29pub mod lenient_uri;
30#[cfg(feature = "otel")]
31pub mod otel;
32pub mod state;
33pub mod telemetry;
34mod user;
35
36#[cfg(feature = "admin-ui")]
37pub mod admin;
38
39pub use app::handle_request;
40pub use build::{build, App, Builder, Host, RESERVED_PREFIXES};
41pub use error::Error;
42pub use state::{AppState, TxOptions};
43pub use user::User;
44
45#[cfg(feature = "admin-ui")]
46pub use admin::admin_router;