Introduction
Thebomboni_request crate provides comprehensive utilities for building and processing API requests that follow Google AIP (API Improvement Proposals) standards. It offers a complete toolkit for implementing production-ready API endpoints with filtering, ordering, pagination, and SQL generation capabilities.
Google AIP Standards
This library implements several key Google AIP standards:AIP-132
Standard List method with pagination, filtering, and ordering support
AIP-160
CEL-based filtering language with logical and comparison operators
Core Concepts
Filtering
Filter expressions use the Common Expression Language (CEL) syntax, supporting:- Logical operators:
AND,OR,NOT - Comparison operators:
=,!=,<,<=,>,>=,: - Complex nested expressions with parentheses
- Field validation against schemas
Ordering
Ordering specifications allow sorting by multiple fields with explicit directions:Pagination
Secure pagination with multiple token types:- Plain: No encoding (development/internal use)
- Base64: Simple encoding
- AES256: Encrypted tokens with symmetric key
- RSA: Encrypted tokens with asymmetric keys
Schema Validation
TheSchemaMapped trait enables type-safe validation of filters and ordering against defined schemas:
When to Use These Utilities
Building List APIs
Building List APIs
Use
ListQueryBuilder when implementing standard list endpoints that need pagination, filtering, and ordering. This is ideal for resource listing endpoints following AIP-132.Search Functionality
Search Functionality
Use
SearchQueryBuilder when you need fuzzy text search combined with filters and pagination. Perfect for search endpoints that need to support query strings.SQL Database Integration
SQL Database Integration
Use
SqlFilterBuilder to convert filter expressions and ordering into SQL WHERE clauses and ORDER BY statements. Supports both PostgreSQL and MySQL dialects.Request Validation
Request Validation
Use the
Parse derive macro to automatically validate and transform incoming API requests (e.g., from Protocol Buffers) into validated domain models.Feature Flags
The crate supports several optional features:| Feature | Description |
|---|---|
derive | Enable derive macros for request parsing |
testing | Enable testing utilities and schemas |
tonic | Enable gRPC integration with tonic |
wasm | Enable WebAssembly support |
postgres | Enable PostgreSQL type conversions |
mysql | Enable MySQL type conversions |
Architecture Overview
The request utilities follow a layered architecture:Parsing Layer
Parse filter strings, ordering specifications, and page tokens from request parameters
Validation Layer
Validate parsed expressions against schemas to ensure type safety and field existence
Next Steps
Filtering
Learn about filter expressions and AIP-160 compliance
Ordering
Understand ordering specifications
Pagination
Implement pagination with ListQuery and SearchQuery
SQL Generation
Convert filters to SQL queries
Parse Derive
Auto-generate request parsers