From b15b56c91bfee90fbe5072abaeaf11d128b6226d Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sun, 9 Aug 2020 01:48:35 +0000 Subject: [PATCH] cgi support --- journal/08-08-2020-maj-cgi-support.gmi | 56 ++++++++++++++++++++++++++ journal/atom.xml | 14 +++---- journal/index.gmi | 1 + 3 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 journal/08-08-2020-maj-cgi-support.gmi diff --git a/journal/08-08-2020-maj-cgi-support.gmi b/journal/08-08-2020-maj-cgi-support.gmi new file mode 100644 index 0000000..5495311 --- /dev/null +++ b/journal/08-08-2020-maj-cgi-support.gmi @@ -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. diff --git a/journal/atom.xml b/journal/atom.xml index 9925033..707cbac 100644 --- a/journal/atom.xml +++ b/journal/atom.xml @@ -2,7 +2,7 @@ gemini://cetacean.club/journal/ Flight Journal - 2020-08-05T20:22:56.094476+00:00 + 2020-08-08T16:21:52.620170+00:00 Cadey Alicia Ratio cadey@firemail.css @@ -10,12 +10,6 @@ python-feedgen - - gemini://cetacean.club/journal/07-26-2020-beginning.gmi - The Beginning - 2020-07-28T14:47:35.176175+00:00 - - gemini://cetacean.club/journal/07-28-2020-dreams-favicons-more.gmi Favicon, Weird Dreams and More @@ -70,4 +64,10 @@ 2020-08-05T20:22:56.094476+00:00 + + gemini://cetacean.club/journal/08-08-2020-maj-cgi-support.gmi + Maj CGI Support + 2020-08-08T16:21:52.620170+00:00 + + diff --git a/journal/index.gmi b/journal/index.gmi index a144ede..fed04f1 100644 --- a/journal/index.gmi +++ b/journal/index.gmi @@ -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-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-08-2020-maj-cgi-support.gmi 8/8/2020 - Maj CGI Support ## 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.