mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-21 13:51:50 +03:00
eyre: add /~/name endpoint
This commit is contained in:
parent
c70e250529
commit
d8ff95db84
@ -1551,6 +1551,9 @@
|
||||
:: gall scry endpoint
|
||||
::
|
||||
[%scry ~]
|
||||
:: internal name endpoint, returns ship @p
|
||||
::
|
||||
[%name ~]
|
||||
:: respond with the default file not found page
|
||||
::
|
||||
[%four-oh-four ~]
|
||||
|
@ -70,7 +70,7 @@
|
||||
++ axle
|
||||
$: :: date: date at which http-server's state was updated to this data structure
|
||||
::
|
||||
date=%~2020.10.18
|
||||
date=%~2022.7.26
|
||||
:: server-state: state of inbound requests
|
||||
::
|
||||
=server-state
|
||||
@ -744,44 +744,58 @@
|
||||
::
|
||||
%scry
|
||||
(handle-scry authenticated address request(url suburl))
|
||||
::
|
||||
%name
|
||||
(handle-name authenticated request)
|
||||
::
|
||||
%four-oh-four
|
||||
%^ return-static-data-on-duct 404 'text/html'
|
||||
(error-page 404 authenticated url.request ~)
|
||||
==
|
||||
:: +handle-name: respond with our @p or 403
|
||||
::
|
||||
++ handle-name
|
||||
|= [authenticated=? =request:http]
|
||||
^- (quip move server-state)
|
||||
?. authenticated
|
||||
(error-response authenticated url.request 403 ~)
|
||||
?. =(%'GET' method.request)
|
||||
(error-response authenticated url.request 405 "may only GET name")
|
||||
%^ return-static-data-on-duct 200 'text/plain'
|
||||
(as-octs:mimes:html (scot %p our))
|
||||
:: +handle-scry: respond with scry result, 404 or 500
|
||||
::
|
||||
++ handle-scry
|
||||
|= [authenticated=? =address =request:http]
|
||||
|^ ^- (quip move server-state)
|
||||
?. authenticated
|
||||
(error-response 403 ~)
|
||||
(error-response authenticated url.request 403 ~)
|
||||
?. =(%'GET' method.request)
|
||||
(error-response 405 "may only GET scries")
|
||||
(error-response authenticated url.request 405 "may only GET scries")
|
||||
:: make sure the path contains an app to scry into
|
||||
::
|
||||
=+ req=(parse-request-line url.request)
|
||||
?. ?=(^ site.req)
|
||||
(error-response 400 "scry path must start with app name")
|
||||
(error-response authenticated url.request 400 "scry path must start with app name")
|
||||
:: attempt the scry that was asked for
|
||||
::
|
||||
=/ res=(unit (unit cage))
|
||||
(do-scry %gx i.site.req (snoc t.site.req (fall ext.req %mime)))
|
||||
?~ res (error-response 500 "failed scry")
|
||||
?~ u.res (error-response 404 "no scry result")
|
||||
?~ res (error-response authenticated url.request 500 "failed scry")
|
||||
?~ u.res (error-response authenticated url.request 404 "no scry result")
|
||||
=* mark p.u.u.res
|
||||
=* vase q.u.u.res
|
||||
:: attempt to find conversion gate to mime
|
||||
::
|
||||
=/ tub=(unit tube:clay)
|
||||
(find-tube i.site.req mark %mime)
|
||||
?~ tub (error-response 500 "no tube from {(trip mark)} to mime")
|
||||
?~ tub (error-response authenticated url.request 500 "no tube from {(trip mark)} to mime")
|
||||
:: attempt conversion, then send results
|
||||
::
|
||||
=/ mym=(each mime tang)
|
||||
(mule |.(!<(mime (u.tub vase))))
|
||||
?- -.mym
|
||||
%| (error-response 500 "failed tube from {(trip mark)} to mime")
|
||||
%| (error-response authenticated url.request 500 "failed tube from {(trip mark)} to mime")
|
||||
%& %+ return-static-data-on-duct 200
|
||||
[(rsh 3 (spat p.p.mym)) q.p.mym]
|
||||
==
|
||||
@ -804,11 +818,6 @@
|
||||
^- (unit (unit cage))
|
||||
(rof ~ care [our desk da+now] path)
|
||||
::
|
||||
++ error-response
|
||||
|= [status=@ud =tape]
|
||||
^- (quip move server-state)
|
||||
%^ return-static-data-on-duct status 'text/html'
|
||||
(error-page status authenticated url.request tape)
|
||||
--
|
||||
:: +subscribe-to-app: subscribe to app and poke it with request data
|
||||
::
|
||||
@ -848,7 +857,7 @@
|
||||
%leave ~
|
||||
==
|
||||
::
|
||||
?(%authentication %logout)
|
||||
?(%authentication %logout %name)
|
||||
[~ state]
|
||||
::
|
||||
%channel
|
||||
@ -875,6 +884,13 @@
|
||||
data=[~ data]
|
||||
complete=%.y
|
||||
==
|
||||
:: +error-response: return error data all at once
|
||||
::
|
||||
++ error-response
|
||||
|= [authenticated=? url=@t status=@ud =tape]
|
||||
^- (quip move server-state)
|
||||
%^ return-static-data-on-duct status 'text/html'
|
||||
(error-page status authenticated url tape)
|
||||
:: +authentication: per-event authentication as this Urbit's owner
|
||||
::
|
||||
:: Right now this hard codes the authentication page using the old +code
|
||||
@ -1071,7 +1087,7 @@
|
||||
^- @t
|
||||
%- crip
|
||||
=; max-age=tape
|
||||
"urbauth-{(scow %p our)}={(scow %uv session)}; Path=/; Max-Age={max-age}"
|
||||
"urbauth-{(scow %p our)}={(scow %uv session)}; Path=/; Max-Age={max-age}; HttpOnly"
|
||||
%- format-ud-as-integer
|
||||
?. extend 0
|
||||
(div (msec:milly session-timeout) 1.000)
|
||||
@ -2207,6 +2223,7 @@
|
||||
[[~ /~/logout] duct [%logout ~]]
|
||||
[[~ /~/channel] duct [%channel ~]]
|
||||
[[~ /~/scry] duct [%scry ~]]
|
||||
[[~ /~/name] duct [%name ~]]
|
||||
==
|
||||
[~ http-server-gate]
|
||||
:: %trim: in response to memory pressure
|
||||
@ -2577,15 +2594,43 @@
|
||||
:: +load: migrate old state to new state (called on vane reload)
|
||||
::
|
||||
++ load
|
||||
|= old=axle
|
||||
=> |%
|
||||
++ axle-old
|
||||
%+ cork
|
||||
axle
|
||||
|= =axle
|
||||
axle(date %~2020.10.18)
|
||||
--
|
||||
|= old=$%(axle axle-old)
|
||||
^+ ..^$
|
||||
:: enable https redirects if certificate configured
|
||||
::
|
||||
=. redirect.http-config.server-state.old
|
||||
?& ?=(^ secure.ports.server-state.old)
|
||||
?=(^ secure.http-config.server-state.old)
|
||||
~! %loading
|
||||
?- -.old
|
||||
%~2020.10.18
|
||||
=/ [* d=duct *]
|
||||
%+ snag 0
|
||||
%+ skim bindings.server-state.old
|
||||
|= [=binding =duct =action]
|
||||
=(%authentication -.action)
|
||||
=/ new
|
||||
%= old
|
||||
date %~2022.7.26
|
||||
::
|
||||
bindings.server-state
|
||||
^- (list [binding duct action])
|
||||
:- [[~ /~/name] d [%name ~]] bindings.server-state.old
|
||||
==
|
||||
..^$(ax old)
|
||||
$(old new)
|
||||
::
|
||||
%~2022.7.26
|
||||
:: enable https redirects if certificate configured
|
||||
::
|
||||
=. redirect.http-config.server-state.old
|
||||
?& ?=(^ secure.ports.server-state.old)
|
||||
?=(^ secure.http-config.server-state.old)
|
||||
==
|
||||
..^$(ax old)
|
||||
==
|
||||
:: +stay: produce current state
|
||||
::
|
||||
++ stay `axle`ax
|
||||
|
@ -2347,5 +2347,5 @@
|
||||
::
|
||||
++ cookie-string
|
||||
%^ cat 3 cookie-value
|
||||
'; Path=/; Max-Age=604800'
|
||||
'; Path=/; Max-Age=604800; HttpOnly'
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user