Turns out the dispatcher takes care of method things for us

parent 1773ae4b
......@@ -62,9 +62,9 @@
(define-values (golem-dispatch golem-url)
(dispatch-rules
[("") actor-profile]
[("inbox") inbox]
[("outbox") outbox]
[("post-note") post-note]
[("inbox") #:method "get" get-inbox]
[("outbox") #:method "get" get-outbox]
[("post-note") #:method "post" post-note]
[("enc" (string-arg)) serve-encrypted-object]))
(define (golem-absolute-url handler)
......@@ -85,48 +85,35 @@
[(cons 'accept str) str]
[#f ""])
","))
(match (request-method req)
[#"GET"
(cond
;; If we get request for json-ld, return that
;; TODO: Accept other json-ld header here, and parse it right
[(member "application/activity+json" headers)
(define profile
`#hasheq((name . ,(users-name))
(inbox . ,(golem-absolute-url-str inbox))
(outbox . ,(golem-absolute-url-str outbox))))
(ok (json->bytes profile)
#:content-type #"application/activity+json")]
;; Return the html page
[else
(render-ok
(generic-base-tmpl
`(div ,(post-note-form)
(p "Hi there! This is " ,(users-name) "'s site."))))])]
[_ (not-allowed)]))
(define (inbox req)
(match (request-method req)
[#"GET"
(cond
;; If we get request for json-ld, return that
;; TODO: Accept other json-ld header here, and parse it right
[(member "application/activity+json" headers)
(define profile
`#hasheq((name . ,(users-name))
(inbox . ,(golem-absolute-url-str get-inbox))
(outbox . ,(golem-absolute-url-str get-outbox))))
(ok (json->bytes profile)
#:content-type #"application/activity+json")]
;; Return the html page
[else
(render-ok
(generic-base-tmpl
'(p "Inbox goes here!")))]
[#"POST"
'TODO]
[_ (not-allowed)]))
(define (outbox req)
(match (request-method req)
[#"GET"
(render-ok
(generic-base-tmpl
'(p "Outbox goes here!")))]
[#"POST"
'TODO]
[_ (not-allowed)]))
`(div ,(post-note-form)
(p "Hi there! This is " ,(users-name) "'s site."))))]))
(define (get-inbox req)
(render-ok
(generic-base-tmpl
'(p "Inbox goes here!"))))
(define (get-outbox req)
(render-ok
(generic-base-tmpl
'(p "Outbox goes here!"))))
(define (post-note req)
'TODO)
(render-ok '(p "Hi there")))
(define (serve-encrypted-object req enc-hash-str)
'TODO)
......@@ -167,10 +154,10 @@
,(users-name) "'s site")
(span (@ (id "site-header-right-stuff"))
,(header-link "inbox"
(golem-url inbox))
(golem-url get-inbox))
" "
,(header-link "outbox"
(golem-url outbox))))
(golem-url get-outbox))))
(div (@ (id "site-main-content"))
,body))
(div (@ (id "site-footer"))
......
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