# facet-axum

Axum integration for Facet - extractors and responses using Facet's serialization.

This crate provides Axum extractors and response types that use Facet's
serialization instead of serde. This allows you to use Facet-derived types
directly in your Axum handlers without needing serde derives.

## Quick start

```rust
use axum::{routing::{get, post}, Router};
use facet::Facet;
use facet_axum::{Json, Query};

#[derive(Debug, Facet)]
struct CreateUser {
    name: String,
    email: String,
}

#[derive(Debug, Facet)]
struct User {
    id: u64,
    name: String,
    email: String,
}

#[derive(Debug, Facet)]
struct SearchParams {
    q: String,
    page: u64,
}

async fn create_user(Json(payload): Json<CreateUser>) -> Json<User> {
    Json(User {
        id: 1,
        name: payload.name,
        email: payload.email,
    })
}

async fn search(Query(params): Query<SearchParams>) -> String {
    format!("Searching for '{}' on page {}", params.q, params.page)
}

let app = Router::new()
    .route("/users", post(create_user))
    .route("/search", get(search));
```

## Feature flags

- `json` (default): Enables `Json<T>` extractor/response using `facet-json`
- `form` (default): Enables `Form<T>` and `Query<T>` extractors using `facet-urlencoded`
- `yaml`: Enables `Yaml<T>` extractor/response using `facet-yaml`
- `toml`: Enables `Toml<T>` extractor/response using `facet-toml`
- `xml`: Enables `Xml<T>` extractor/response using `facet-xml`
- `kdl`: Enables `Kdl<T>` extractor/response using `facet-kdl`
- `msgpack`: Enables `MsgPack<T>` extractor/response using `facet-msgpack`
- `postcard`: Enables `Postcard<T>` extractor/response using `facet-postcard`
- `all`: Enables all format features


