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