cgi support

This commit is contained in:
Cadey Ratio 2020-08-09 01:48:35 +00:00
parent 7d889446fc
commit b15b56c91b
3 changed files with 64 additions and 7 deletions

View File

@ -0,0 +1,56 @@
# Maj CGI Support
I have just released Maj 0.6.0 which brings support for CGI[1] to the framework. This allows arbitrary other programs to run as handlers for Maj and confirms to the specification made by Jetforce[2].
=> https://tools.ietf.org/rfc/rfc3875.txt [1]: CGI
=> https://github.com/michael-lazar/jetforce [2]: Jetforce
For a few examples of this, see the following URLs:
=> /cgi-bin/env.sh
=> /cgi-bin/olinfetch.wasm
This also includes support for running programs written with WebAssembly using pa'i[3]. Here is the source code that powers olinfetch.wasm:
```
#![no_main]
#![feature(start)]
extern crate olin;
use anyhow::{anyhow, Result};
use olin::{entrypoint, env, runtime, stdio, time};
use std::io::Write;
entrypoint!();
fn main() -> Result<()> {
let mut out = stdio::out();
if let Ok(url) = env::get("GEMINI_URL") {
write!(out, "20 text/gemini\n# WebAssembly Runtime Information\n")?;
write!(out, "URL: {}\n", url)?;
write!(
out,
"Server software: {}\n",
env::get("SERVER_SOFTWARE").unwrap()
)?;
}
let mut rt_name = [0u8; 32];
let runtime_name = runtime::name_buf(rt_name.as_mut())
.ok_or_else(|| anyhow!("Runtime name larger than 32 byte limit"))?;
write!(out, "CPU: {}\n", "wasm32").expect("write to work");
write!(
out,
"Runtime: {} {}.{}\n",
runtime_name,
runtime::spec_major(),
runtime::spec_minor()
)?;
write!(out, "Now: {}\n", time::now().to_rfc3339())?;
Ok(())
}
```
This allows users to write custom behavior in any language that can compile to WebAssembly. This will also allow this custom behavior to be moved across machines to any CPU or operating system that can run the WebAssembly runtime. This allows trivial mobility between processor types, allowing users to not be beholden to individual vendors or operating systems.

View File

@ -2,7 +2,7 @@
<feed xmlns="http://www.w3.org/2005/Atom"> <feed xmlns="http://www.w3.org/2005/Atom">
<id>gemini://cetacean.club/journal/</id> <id>gemini://cetacean.club/journal/</id>
<title>Flight Journal</title> <title>Flight Journal</title>
<updated>2020-08-05T20:22:56.094476+00:00</updated> <updated>2020-08-08T16:21:52.620170+00:00</updated>
<author> <author>
<name>Cadey Alicia Ratio</name> <name>Cadey Alicia Ratio</name>
<email>cadey@firemail.css</email> <email>cadey@firemail.css</email>
@ -10,12 +10,6 @@
<link href="gemini://cetacean.club/journal/atom.xml" rel="self"/> <link href="gemini://cetacean.club/journal/atom.xml" rel="self"/>
<link href="gemini://cetacean.club/journal/" rel="alternate"/> <link href="gemini://cetacean.club/journal/" rel="alternate"/>
<generator uri="https://lkiesow.github.io/python-feedgen" version="0.9.0">python-feedgen</generator> <generator uri="https://lkiesow.github.io/python-feedgen" version="0.9.0">python-feedgen</generator>
<entry>
<id>gemini://cetacean.club/journal/07-26-2020-beginning.gmi</id>
<title>The Beginning</title>
<updated>2020-07-28T14:47:35.176175+00:00</updated>
<link href="gemini://cetacean.club/journal/07-26-2020-beginning.gmi" rel="alternate"/>
</entry>
<entry> <entry>
<id>gemini://cetacean.club/journal/07-28-2020-dreams-favicons-more.gmi</id> <id>gemini://cetacean.club/journal/07-28-2020-dreams-favicons-more.gmi</id>
<title>Favicon, Weird Dreams and More</title> <title>Favicon, Weird Dreams and More</title>
@ -70,4 +64,10 @@
<updated>2020-08-05T20:22:56.094476+00:00</updated> <updated>2020-08-05T20:22:56.094476+00:00</updated>
<link href="gemini://cetacean.club/journal/08-05-2020-rpg-backstory-gen.gmi" rel="alternate"/> <link href="gemini://cetacean.club/journal/08-05-2020-rpg-backstory-gen.gmi" rel="alternate"/>
</entry> </entry>
<entry>
<id>gemini://cetacean.club/journal/08-08-2020-maj-cgi-support.gmi</id>
<title>Maj CGI Support</title>
<updated>2020-08-08T16:21:52.620170+00:00</updated>
<link href="gemini://cetacean.club/journal/08-08-2020-maj-cgi-support.gmi" rel="alternate"/>
</entry>
</feed> </feed>

View File

@ -17,6 +17,7 @@ These logs will contain thoughts, feelings, major events in my life and other su
=> 08-01-2020-hosted-with-maj.gmi 8/1/2020 - This site is hosted with Maj => 08-01-2020-hosted-with-maj.gmi 8/1/2020 - This site is hosted with Maj
=> 08-05-2020-lewa-development.gmi 8/5/2020 - L'ewa Development => 08-05-2020-lewa-development.gmi 8/5/2020 - L'ewa Development
=> 08-05-2020-rpg-backstory-gen.gmi 8/5/2020 - RPG Character Backstory Generator => 08-05-2020-rpg-backstory-gen.gmi 8/5/2020 - RPG Character Backstory Generator
=> 08-08-2020-maj-cgi-support.gmi 8/8/2020 - Maj CGI Support
## Stories ## Stories
Occasionally I write little stories that are not really connected to anything. I have not really had a good place to publish these in the past. This place seems as good as any. Occasionally I write little stories that are not really connected to anything. I have not really had a good place to publish these in the past. This place seems as good as any.