aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/world/net/http/route.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/world/net/http/route.lux')
-rw-r--r--stdlib/source/lux/world/net/http/route.lux73
1 files changed, 0 insertions, 73 deletions
diff --git a/stdlib/source/lux/world/net/http/route.lux b/stdlib/source/lux/world/net/http/route.lux
deleted file mode 100644
index 32bdf1213..000000000
--- a/stdlib/source/lux/world/net/http/route.lux
+++ /dev/null
@@ -1,73 +0,0 @@
-(.module:
- [lux (#- or)
- [control
- [monad (#+ do)]
- [concurrency
- ["." promise]]]
- [data
- ["." maybe]
- ["." text]
- [number
- ["n" nat]]]]
- ["." // (#+ URI Server)
- ["#." status]
- ["#." response]])
-
-(template [<scheme> <name>]
- [(def: #export (<name> server)
- (-> Server Server)
- (function (_ (^@ request [identification protocol resource message]))
- (case (get@ #//.scheme protocol)
- <scheme>
- (server request)
-
- _
- (promise.resolved //response.not-found))))]
-
- [#//.HTTP http]
- [#//.HTTPS https]
- )
-
-(template [<method> <name>]
- [(def: #export (<name> server)
- (-> Server Server)
- (function (_ (^@ request [identification protocol resource message]))
- (case (get@ #//.method resource)
- <method>
- (server request)
-
- _
- (promise.resolved //response.not-found))))]
-
- [#//.Get get]
- [#//.Post post]
- [#//.Put put]
- [#//.Patch patch]
- [#//.Delete delete]
- [#//.Head head]
- [#//.Connect connect]
- [#//.Options options]
- [#//.Trace trace]
- )
-
-(def: #export (uri path server)
- (-> URI Server Server)
- (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)
- (function (_ request)
- (do promise.monad
- [response (primary request)
- #let [[status message] response]]
- (if (n.= //status.not-found status)
- (alternative request)
- (wrap response)))))