server: fix session js caching, add cache threading for other response types, switch from tape to cord interpolation

This commit is contained in:
Logan Allen 2021-04-16 12:58:27 -05:00
parent 6e476cfdf2
commit 751f3d1f24
2 changed files with 43 additions and 29 deletions

View File

@ -188,8 +188,11 @@
?: ?=([%'~landscape' %js %session ~] site.req-line)
%+ require-authorization-simple:app
inbound-request
%- js-response:gen
(as-octt:mimes:html "window.ship = '{+:(scow %p our.bowl)}';")
%. %- as-octs:mimes:html
:((cury cat 3) 'window.ship = "' (rsh 3 (scot %p our.bowl)) '";')
%* . js-response:gen
cache %.n
==
::
=/ [payload=simple-payload:http public=?] (get-file req-line is-file)
?: public payload

View File

@ -39,10 +39,10 @@
~! +:*handler
(handler inbound-request)
::
=/ redirect=cord
%- crip
"/~/login?redirect={(trip url.request.inbound-request)}"
[[307 ['location' redirect]~] ~]
=- [[307 ['location' -]~] ~]
%^ cat 3
'/~/login?redirect='
url.request.inbound-request
::
:: +require-authorization-simple:
:: redirect to the login page when unauthenticated
@ -56,10 +56,10 @@
~! this
simple-payload
::
=/ redirect=cord
%- crip
"/~/login?redirect={(trip url.request.inbound-request)}"
[[307 ['location' redirect]~] ~]
=- [[307 ['location' -]~] ~]
%^ cat 3
'/~/login?redirect='
url.request.inbound-request
::
++ give-simple-payload
|= [eyre-id=@ta =simple-payload:http]
@ -86,36 +86,47 @@
:_ `octs
[200 [['content-type' 'text/html'] ?:(cache [max-1-wk ~] ~)]]
::
++ js-response
|= =octs
^- simple-payload:http
[[200 [['content-type' 'text/javascript'] max-1-da ~]] `octs]
::
++ json-response
|= =json
^- simple-payload:http
[[200 ['content-type' 'application/json']~] `(json-to-octs json)]
::
++ css-response
=| cache=?
|= =octs
^- simple-payload:http
[[200 [['content-type' 'text/css'] max-1-da ~]] `octs]
:_ `octs
[200 [['content-type' 'text/css'] ?:(cache [max-1-wk ~] ~)]]
::
++ manx-response
|= man=manx
++ js-response
=| cache=?
|= =octs
^- simple-payload:http
[[200 ['content-type' 'text/html']~] `(manx-to-octs man)]
:_ `octs
[200 [['content-type' 'text/javascript'] ?:(cache [max-1-wk ~] ~)]]
::
++ png-response
=| cache=?
|= =octs
^- simple-payload:http
[[200 [['content-type' 'image/png'] max-1-wk ~]] `octs]
:_ `octs
[200 [['content-type' 'image/png'] ?:(cache [max-1-wk ~] ~)]]
::
++ woff2-response
=| cache=?
|= =octs
^- simple-payload:http
[[200 [['content-type' 'font/woff2'] max-1-wk ~]] `octs]
::
++ json-response
=| cache=_|
|= =json
^- simple-payload:http
:_ `(json-to-octs json)
[200 [['content-type' 'application/json'] ?:(cache [max-1-da ~] ~)]]
::
++ manx-response
=| cache=_|
|= man=manx
^- simple-payload:http
:_ `(manx-to-octs man)
[200 [['content-type' 'text/html'] ?:(cache [max-1-da ~] ~)]]
::
++ not-found
^- simple-payload:http
[[404 ~] ~]
@ -123,10 +134,10 @@
++ login-redirect
|= =request:http
^- simple-payload:http
=/ redirect=cord
%- crip
"/~/login?redirect={(trip url.request)}"
[[307 ['location' redirect]~] ~]
=- [[307 ['location' -]~] ~]
%^ cat 3
'/~/login?redirect='
url.request
::
++ redirect
|= redirect=cord