Expand description
Cot is an easy to use, modern, and fast web framework for Rust. It has been designed to be familiar if you’ve ever used Django, and easy to learn if you haven’t. It’s a batteries-included framework built on top of axum.
§Features
- Easy to use API — in many ways modeled after Django, Cot’s API is designed to be easy to use and intuitive. Sensible defaults make it for easy rapid development, while the API is still empowering you when needed. The documentation is a first-class citizen in Cot, making it easy to find what you’re looking for.
- ORM integration — Cot comes with its own ORM, allowing you to interact with your database in a way that feels Rusty and intuitive. Rust types are the source of truth, and the ORM takes care of translating them to and from the database, as well as creating the migrations automatically.
- Type safe — wherever possible, Cot uses Rust’s type system to prevent common mistakes and bugs. Not only views are taking advantage of the Rust’s type system, but also the ORM, the admin panel, and even the templates. All that to catch errors as early as possible.
- Admin panel — Cot comes with an admin panel out of the box, allowing you to manage your app’s data with ease. Adding new models to the admin panel is stupidly simple, making it a great tool not only for rapid development and debugging, but with its customization options, also for production use.
- Secure by default — security should be opt-out, not opt-in. Cot takes care of making your web apps secure by default, defending it against common modern web vulnerabilities. You can focus on building your app, not securing it.
§Guide
This is an API reference for Cot, which might not be the best place to start learning Cot. For a more gentle introduction, see the Cot guide.
§Examples
To see examples of how to use Cot, see the examples in the repository.
Re-exports§
pub use crate::project::App;
pub use crate::project::AppBuilder;
pub use crate::project::Bootstrapper;
pub use crate::project::Project;
pub use crate::project::ProjectContext;
pub use crate::project::run;
pub use crate::project::run_at;
pub use crate::project::run_cli;
pub use aide;
openapi
pub use schemars;
openapi
pub use bytes;
pub use http;
Modules§
- admin
- Administration panel.
- auth
- Authentication system for Cot.
- cli
- A command line interface for Cot-based applications.
- common_
types - Form Field Types for Cot
- config
- Configuration data for the project.
- db
db
- Database support along with migration engine and ORM.
- form
- Forms and form fields for handling user input.
- html
- HTML rendering utilities.
- json
json
- JSON rendering utilities.
- middleware
- Middlewares for modifying requests and responses.
- openapi
openapi
- OpenAPI integration for Cot.
- project
- This module contains the core types and traits for a Cot project.
- request
- HTTP request type and helper methods.
- response
- HTTP response type and helper methods.
- router
- Router for passing requests to their respective views.
- session
- Session management
- static_
files - Static files middleware.
- test
test
- Test utilities for Cot projects.
Macros§
- metadata
- A macro to generate a
CliMetadata
struct from the Cargo manifest. - reverse
- Get a URL for a view by its registered name and given params.
- reverse_
redirect - Get a URL for a view by its registered name and given params and return a response with a redirect.
- static_
files - Macro to define static files by specifying their paths.
Structs§
- Body
- A type that represents an HTTP request or response body.
- Error
- An error that can occur while using Cot.
Traits§
- Request
Handler - A function that takes a request and returns a response.
Type Aliases§
- Boxed
Handler - A wrapper around a handler that’s used in
Bootstrapper
. - Method
- A type alias for an HTTP method.
- Result
- A type alias for a result that can return a
cot::Error
. - Status
Code - A type alias for an HTTP status code.