Skip to main content

Crate reinhardt_rest

Crate reinhardt_rest 

Source
Expand description

§Reinhardt REST

Unified REST API framework for Reinhardt.

This crate provides a complete REST API framework by integrating:

  • Serializers: Data serialization and validation (from reinhardt-serializers)
  • Parsers: Request body parsing (from reinhardt-parsers)
  • Authentication: JWT, Token, Session, Basic auth (from reinhardt-auth)
  • Routers: Automatic URL routing for ViewSets (from reinhardt-routers)
  • Browsable API: HTML interface for API exploration (from reinhardt-browsable-api)

§Quick Start

use reinhardt_rest::parsers::JSONParser;

// Create a JSON parser for handling JSON request bodies
let parser = JSONParser::new();

For router integration, see the reinhardt_urls::routers crate.

§Architecture

Key modules in this crate:

  • browsable_api: HTML interface for interactive API exploration
  • filters: Query parameter filtering for list endpoints
  • metadata: API metadata and schema introspection utilities
  • serializers: Data serialization, deserialization, and validation
  • throttling: Request rate limiting and throttle policies
  • versioning: API versioning strategies (URL path, header, query)
  • authentication: REST authentication backends (JWT, Token, Session, Basic)
  • response: Typed API response wrappers and pagination support
  • schema: OpenAPI schema generation (requires openapi feature)

§Feature Flags

FeatureDefaultDescription
serializersenabledData serialization and validation components
parsersenabledRequest body parsing (JSON, Form, Multipart)
jwtdisabledJWT authentication backend
filtersdisabledQuery parameter filtering for querysets
throttlingdisabledRequest rate limiting policies
versioningdisabledAPI versioning strategies
metadatadisabledAPI introspection and schema metadata
paginationdisabledCursor and page-number pagination
browsable-apidisabledHTML browsable API interface
openapidisabledOpenAPI/Swagger schema generation and UI
rest-fulldisabledEnables all REST features

§Testing

This crate contains unit tests for the integrated modules. Integration tests are located in tests/integration/.

Re-exports§

pub use authentication::AuthResult;
pub use response::ApiResponse;
pub use response::IntoApiResponse;
pub use response::ResponseBuilder;
pub use crate::serializers::ModelSerializer;
pub use crate::serializers::UniqueTogetherValidator;
pub use crate::serializers::UniqueValidator;
pub use crate::browsable_api::*;

Modules§

authentication
REST API authentication
browsable_api
Browsable API for Reinhardt
filters
Type-safe filtering backends for Reinhardt framework
metadata
Reinhardt Metadata
negotiation
Content negotiation for request/response formats. Content negotiation for Reinhardt
pagination
Pagination strategies (page-based, cursor, limit-offset).
parsers
Request body parsers (JSON, form, multipart, etc.).
response
REST API response types
serializers
Reinhardt Serializers
throttling
Rate limiting for Reinhardt framework
versioning
Reinhardt Versioning

Macros§

versioned_handler
Macro for creating versioned handlers easily
versioned_url
Macro for easy URL building

Structs§

AllowAny
AllowAny - grants permission to all requests
AnonymousUser
Anonymous user - represents a non-authenticated visitor
ContentNegotiator
Content Negotiation - Re-exports from reinhardt-negotiation Content negotiator for selecting appropriate renderer
FileUploadParser
Raw file upload parser
FormParser
Form parser for application/x-www-form-urlencoded content type
IsAdminUser
IsAdminUser - requires the user to be an admin
IsAuthenticated
IsAuthenticated - requires the user to be authenticated
IsAuthenticatedOrReadOnly
IsAuthenticatedOrReadOnly - authenticated for writes, allow reads
JSONParser
JSON parser for application/json content type
JsonSerializer
JSON serializer implementation
MediaType
Media type representation
MultiPartParser
MultiPart parser for multipart/form-data content type (file uploads)
PaginatedResponse
Paginated response wrapper
SimpleUser
Simple user implementation with basic fields

Enums§

SerializerError
Errors that can occur during serialization

Traits§

AuthBackend
Authentication backend trait
Deserializer
Deserializer trait for one-way deserialization
Parser
Trait for request body parsers
Permission
Permission trait - defines permission checking interface
Serializer
Core serializer trait for converting between input and output representations
UserDeprecated
User trait - Core authentication trait

Type Aliases§

ParseError
Type alias for parser errors, using the framework’s Error type.
ParseResult
Type alias for parser results, using the framework’s Result type.