Crate at_jet

Crate at_jet 

Source
Expand description

§AT-Jet

High-performance HTTP + Protobuf API framework for mobile services. AT-Jet provides a clean, ergonomic way to build HTTP APIs that use Protocol Buffers for serialization - ideal for mobile clients that need efficient bandwidth usage and strong schema evolution guarantees.

§Features

  • HTTP/1.1 and HTTP/2 support via axum
  • Protobuf request/response handling with automatic content negotiation
  • Dual-format support - Protobuf for production, JSON for debugging
  • CDN-friendly design for global mobile users
  • Middleware support for authentication, logging, compression
  • Type-safe routing with compile-time guarantees

§Quick Start

use at_jet::prelude::*;
use bytes::Bytes;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let app = JetServer::new()
        .route("/api/user/:id", get(get_user))
        .route("/api/user", post(create_user));

    app.serve("0.0.0.0:8080").await?;
    Ok(())
}

// Dual-format: accepts both protobuf and JSON, responds based on Accept header
async fn get_user(Path(id): Path<i32>) -> ProtobufResponse<User> {
    let user = User { id, name: "John".to_string() };
    ProtobufResponse::ok(user)
}

async fn create_user(ApiRequest { body, format }: ApiRequest<CreateUserRequest>) -> ApiResponse<User> {
    // body is decoded from either protobuf or JSON based on Content-Type
    // response format matches the Accept header
    ApiResponse::ok(format, user)
}

Modules§

client
HTTP Client for AT-Jet
content_types
Content types used by AT-Jet
dual_format
Dual-format support for AT-Jet
error
Error types for AT-Jet
extractors
Request extractors for AT-Jet
middleware
Middleware for AT-Jet
prelude
Re-exports for convenient usage
response
Response types for AT-Jet
server
HTTP Server implementation for AT-Jet