You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Garrit Franke f425656615
chore(gempress): migrate to openssl
3 years ago
..
examples gempress: return result from function handlers 3 years ago
src chore(gempress): migrate to openssl 3 years ago
Cargo.lock gempress: v0.1.1 3 years ago
Cargo.toml chore(gempress): migrate to openssl 3 years ago
README.md gempress: add API documentation, readme 3 years ago
make_cert.sh chore(gempress): migrate to openssl 3 years ago

README.md

Gempress

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.

A simple server

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.

Generating a self-signed certificate

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