Commit b45551f1 authored by Christopher Lemmer Webber's avatar Christopher Lemmer Webber

shell site structure

parents
#lang racket
(require html-writing
net/url
web-server/servlet
web-server/servlet-env
web-server/dispatch
magenc/install-factory)
(define-values (golem-dispatch golem-url)
(dispatch-rules
[("") homepage]
[("live" (string-arg)) live-object]
[("live" (string-arg) "inbox") live-object-inbox]
[("live" (string-arg) "outbox") live-object-outbox]
[("enc" (string-arg)) serve-encrypted-object]
[else four-oh-four]))
(define (ok body #:content-type [content-type #"application/octet-stream"])
(response
200 #"OK"
(current-seconds) content-type
'()
(lambda (out-port)
(write-bytes body out-port))))
(define (render-ok sxml)
(ok (xexp->html-bytes sxml)
#:content-type #"text/html"))
(define (homepage req)
(render-ok '(html (title "It's ok")
(body (p "Everything will be ok")))))
(define (live-object req obj-id)
'TODO)
(define (live-object-inbox req obj-id)
'TODO)
(define (live-object-outbox req obj-id)
'TODO)
(define (serve-encrypted-object req enc-hash-str)
'TODO)
(define (decrypt-encrypted-object req enc-hash-str-key)
'TODO)
(define (four-oh-four req)
(response
404 #"NOT FOUND"
(current-seconds) #"text/plain"
'()
(lambda (out-port)
(write-bytes #"Not found X_X" out-port))))
(define (start request)
(golem-dispatch request))
(define (main)
(serve/servlet start
#:servlet-regexp #rx""
#:launch-browser? #f)
(void))
(module+ main
(install-default-factories!)
(main))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment