diff options
Diffstat (limited to 'stdlib/source/lux/world/net/http/route.lux')
-rw-r--r-- | stdlib/source/lux/world/net/http/route.lux | 57 |
1 files changed, 22 insertions, 35 deletions
diff --git a/stdlib/source/lux/world/net/http/route.lux b/stdlib/source/lux/world/net/http/route.lux index d7b674366..c15972ca6 100644 --- a/stdlib/source/lux/world/net/http/route.lux +++ b/stdlib/source/lux/world/net/http/route.lux @@ -3,9 +3,7 @@ [control [monad (#+ do)] [concurrency - ["." promise]] - [security - ["." integrity]]] + ["." promise]]] [data ["." maybe] ["." text ("text/." equivalence)]]] @@ -16,14 +14,13 @@ (do-template [<scheme> <name>] [(def: #export (<name> server) (-> Server Server) - (function (_ request) - (let [[identification protocol resource message] (integrity.trust request)] - (case (get@ #//.scheme protocol) - <scheme> - (server request) + (function (_ (^@ request [identification protocol resource message])) + (case (get@ #//.scheme protocol) + <scheme> + (server request) - _ - (promise.resolved //response.not-found)))))] + _ + (promise.resolved //response.not-found))))] [#//.HTTP http] [#//.HTTPS https] @@ -32,14 +29,13 @@ (do-template [<method> <name>] [(def: #export (<name> server) (-> Server Server) - (function (_ request) - (let [[identification protocol resource message] (integrity.trust request)] - (case (get@ #//.method resource) - <method> - (server request) + (function (_ (^@ request [identification protocol resource message])) + (case (get@ #//.method resource) + <method> + (server request) - _ - (promise.resolved //response.not-found)))))] + _ + (promise.resolved //response.not-found))))] [#//.Get get] [#//.Post post] @@ -54,24 +50,15 @@ (def: #export (uri path server) (-> URI Server Server) - (function (_ request) - (let [[identification protocol resource message] (integrity.trust request)] - (if (text/= path (get@ #//.uri resource)) - (server request) - (promise.resolved //response.not-found))))) - -(def: #export (sub path server) - (-> URI Server Server) - (function (_ request) - (let [[identification protocol resource message] (integrity.trust request)] - (if (text.starts-with? path (get@ #//.uri resource)) - (server (integrity.taint [identification - protocol - (update@ #//.uri - (|>> (text.clip' (text.size path)) maybe.assume) - resource) - message])) - (promise.resolved //response.not-found))))) + (function (_ [identification protocol resource message]) + (if (text.starts-with? path (get@ #//.uri resource)) + (server [identification + protocol + (update@ #//.uri + (|>> (text.clip' (text.size path)) maybe.assume) + resource) + message]) + (promise.resolved //response.not-found)))) (def: #export (or primary alternative) (-> Server Server Server) |