Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carterisonline/hyro
Hypermedia Rust Orchestration
https://github.com/carterisonline/hyro
Last synced: 3 months ago
JSON representation
Hypermedia Rust Orchestration
- Host: GitHub
- URL: https://github.com/carterisonline/hyro
- Owner: carterisonline
- Created: 2023-07-02T03:24:27.000Z (over 1 year ago)
- Default Branch: trunk
- Last Pushed: 2024-04-25T00:43:41.000Z (9 months ago)
- Last Synced: 2024-04-25T02:14:38.328Z (9 months ago)
- Language: Rust
- Homepage:
- Size: 181 KB
- Stars: 23
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
### HYRO
noun
/ˈhɪr.oʊ/1. A : acronym for "Hypermedia Rust Orchestration"
B : a crate that extends existing frameworks like [Axum](https://github.com/tokio-rs/axum/) with new functionality, like
rendering [Jinja Templates](https://github.com/mitsuhiko/minijinja) on the server,
[bundling css](https://github.com/parcel-bundler/lightningcss), and a better developer experience.
C : a powerful HMR framework for [hypermedia systems](https://hypermedia.systems/) like [HTMX](https://htmx.org/).
D : the equivalent of [Rails](https://rubyonrails.org/) for nerds## Usage and Examples
- More in-depth examples can be found in the [examples folder](examples/). Make sure you `cd` to the path containing
the templates and style folders before running or _you will get a file-not-found error!_Let's start with dependencies. We'll be using axum as our framework, and tokio as our runtime:
```sh
cargo new hyro-getting-startedcargo add hyro -F framework-axum
cargo add axum
cargo add tokio -F full
mkdir templates
```HYRO templates use Jinja2. Let's start with a basic one:
`templates/hello.html.jinja2`
```html
Hello, {{ name }}!
```Then we can set up our boilerplate:
`src/main.rs`
```rust
use std::borrow::Cow;use axum::response::Html;
use axum::{routing, Router, Server};
use hyro::prelude::*;
use hyro::{context, Template};#[tokio::main]
async fn main() {
let router = Router::new()
.route("/hello", routing::get(hello))
.into_service_with_hmr();Server::from_tcp(hyro::bind("0.0.0.0:1380"))).unwrap()
.serve(router)
.await
.unwrap();
}async fn hello(template: Template) -> Html> {
template.render(context! {
name => "World",
})
}
```Now if we navigate to 'localhost:1380/hello', we can read our message! If you're running in
debug mode, you can edit `templates/hello.html.jinja2` and the HMR should kick in.