2 ms·
Most frameworks in rust a like Sinatra and Flask. There aren't any Rails level frameworks. I don't think there are any Rails level frameworks besides Django and
by 0x457 4y ago
Most frameworks in rust a like Sinatra and Flask. There aren't any Rails level frameworks. I don't think there are any Rails level frameworks besides Django and a few JVM frameworks.
Rust web frameworks just give you tools to get from request to response, the rest is up to you. I think that is fine, yeah it leads to some boilerplate to wire up a few libraries together, but you did it once, and you're done.
- theironhammer 4y agoThere's this: https://rust-on-nails.com https://rust-on-nails.com
- 0x457 4y agoYes, anyone can call `X on Rails`, but look at the first example here: https://rust-on-nails.com/docs/full-stack-web/web-server/ https://rust-on-nails.com/docs/full-stack-web/web-server/ Does it look like anything close to Ruby on Rails in terms of tooling? No, because Rust on Nails doesn't provide any tools at all. It literally doesn't take care of anything, but provides some (questionable) decisions made for you. You know what I've never done in RoR? This: use std::env; use std::str::FromStr; #[derive(Clone, Debug)] pub struct Config { pub database_url: String, } impl Config { pub fn new() -> Config { let database_url = env::var("DATABASE_URL").expect("DATABASE_URL not set"); Config { database_url, } } pub fn create_pool(&self) -> deadpool_postgres::Pool { let config = tokio_postgres::Config::from_str(&self.database_url).unwrap(); let manager = if self.database_url.contains("sslmode=require") { let mut root_store = rustls::RootCertStore::empty(); root_store.add_server_trust_anchors( webpki_roots::TLS_SERVER_ROOTS .0 .iter() .map(|ta| { rustls::OwnedTrustAnchor::from_subject_spki_name_constraints( ta.subject, ta.spki, ta.name_constraints, ) }) ); let tls_config = rustls::ClientConfig::builder() .with_safe_defaults() .with_root_certificates(root_store) .with_no_client_auth(); let tls = tokio_postgres_rustls::MakeRustlsConnect::new(tls_config); deadpool_postgres::Manager::new(config, tls) } else { deadpool_postgres::Manager::new(config, tokio_postgres::NoTls) }; deadpool_postgres::Pool::builder(manager).build().unwrap() } }