Crates.io | gempress |
lib.rs | gempress |
version | 0.1.1 |
source | src |
created_at | 2021-09-05 23:02:01.310974 |
updated_at | 2021-09-05 23:08:48.402297 |
description | An Express.js inspired server framework for the gemini protocol |
homepage | |
repository | https://github.com/garritfra/astrofarm/tree/main/lib/gempress |
max_upload_size | |
id | 447319 |
size | 26,858 |
An Express.js inspired server framework for the Gemini protocol.
The goal of Gempress is to provide a minimal yet powerful API to build dynamic gemini applications.
Setting up a Gempress server with a single route looks like this:
fn index_handler(req: Box<gemini::Request>, mut res: Box<gemini::Response>) {
res.send("Hello from index route!".as_bytes());
}
fn main() {
let config = gempress::Config::from_identity(PathBuf::from("identity.pfx"), "password".into());
let mut app = Gempress::new(config);
app.on("/", &index_handler);
app.listen(1965, || {
println!("Listening on port 1965");
})
.unwrap();
}
See the examples directory for more elaborate examples.
To use a Gempress server, you will need a TLS certificate bundled in an
identity. To generate a certificate, simply execute the following snippet.
Substitute the localhost
with your own hostname to generate a certificate
exposed to the public.
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj '/CN=localhost'
openssl pkcs12 -export -out identity.pfx -inkey key.pem -in cert.pem
# Cleanup old files
rm key.pem cert.pem