~ vial: a micro micro-framework ~
vial
is a small web "framework" for making small web "sites".
It only includes a few basics:
- Parsing and routing HTTP requests
- Handling POST requests
- Serving static files (css, js)
Everything else... well, that's up to you.
The goal is an as-few-as-possible-dependencies web library you can use to test out an idea quickly or get a static site rolling. Single file, server side apps? You bet! Fast compilation? Yes please! À la carte dependencies? Now you're really talkin'!
It's sort of like a picnic where the playlist is all 90s music and you have to bring your own beverage.
To get started, just add vial
to your Cargo.toml
:
[]
= "*"
~ hello world ~
As is tradition:
!
routes
For a bit more sanity, you can route to functions directly:
use *;
routes!
To really break the mold, you can split your site into different modules:
use vial;
But hey, who wants to putz around with HTML when you can be writing
Rust? Enable the horror
feature and you're on your way:
use *;
routes!
~ hot reloading ~
Install cargo-watch:
$ cargo install cargo-watch
$ cargo watch -x 'run --example hello_world'
~ bonus features ~
vial doesn't come with JSON or a template engine or any of that
fancy stuff, but there are a few compile-time --features
you can
activate for enhanced productivity:
- cookies: Cookie monster!
- sessions: Session Support
- markdown: Add Markdown rendering capabilities.
- horror: Small & fast macro-based HTML builder, via horrowshow.
- json:
to_json
andfrom_json
powers, via Serde. - tera: Templating, via Tera.
- hatter: Barebones, no-dependency template library, via hatter.
- gzip: Serve pages with gzip compression.
- ssl: Add support for SSL/TLS. Normally you should be using a proxy.
Please note: The list above is a work-in-progress.
~ T0D0 ~
- tests
- document each feature in manual
- don't copy any of raw HTTP request
-
before_filter
- cookies
- sessions
- state
warp's features:
- Path routing and parameter extraction
- Header requirements and extraction
- Query string deserialization
- JSON and [x] Form bodies
- Multipart form data
- Static Files and Directories
- Websockets
- Access logging
- Gzip, Deflate, and Brotli compression