aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/control/concurrency/promise.lux2
-rw-r--r--stdlib/source/lux/data/format/context.lux6
-rw-r--r--stdlib/source/lux/world/net/http.lux11
-rw-r--r--stdlib/source/lux/world/net/http/response.lux14
4 files changed, 24 insertions, 9 deletions
diff --git a/stdlib/source/lux/control/concurrency/promise.lux b/stdlib/source/lux/control/concurrency/promise.lux
index 31d620b64..33a04190b 100644
--- a/stdlib/source/lux/control/concurrency/promise.lux
+++ b/stdlib/source/lux/control/concurrency/promise.lux
@@ -3,7 +3,7 @@
[control
[functor (#+ Functor)]
[apply (#+ Apply)]
- ["." monad (#+ do Monad)]]
+ ["." monad (#+ Monad do)]]
[data
["." product]]
["." function]
diff --git a/stdlib/source/lux/data/format/context.lux b/stdlib/source/lux/data/format/context.lux
index 749185f85..715489072 100644
--- a/stdlib/source/lux/data/format/context.lux
+++ b/stdlib/source/lux/data/format/context.lux
@@ -6,7 +6,7 @@
[monad (#+ do)]]
[data
["." error (#+ Error)]
- [text
+ ["." text
format]
[collection
["." dictionary (#+ Dictionary)]]]])
@@ -20,6 +20,10 @@
(type: #export (Property a)
(Parser Context a))
+(def: #export empty
+ Context
+ (dictionary.new text.Hash<Text>))
+
(def: #export (property name)
(-> Text (Property Text))
(function (_ context)
diff --git a/stdlib/source/lux/world/net/http.lux b/stdlib/source/lux/world/net/http.lux
index 36809c28f..04e7ef829 100644
--- a/stdlib/source/lux/world/net/http.lux
+++ b/stdlib/source/lux/world/net/http.lux
@@ -1,12 +1,12 @@
(.module:
[lux #*
+ [control
+ [concurrency
+ [promise (#+ Promise)]
+ [frp (#+ Channel)]]]
[data
- [error (#+ Error)]
[format
[context (#+ Context)]]]
- [concurrency
- [promise (#+ Promise)]
- [frp (#+ Channel)]]
[world
[binary (#+ Binary)]]]
[// (#+ URL)])
@@ -17,6 +17,7 @@
#Post
#Get
#Put
+ #Patch
#Delete
#Head
#Connect
@@ -72,4 +73,4 @@
[Status Payload])
(type: #export Server
- (-> Request (Promise (Error Response))))
+ (-> Request (Promise Response)))
diff --git a/stdlib/source/lux/world/net/http/response.lux b/stdlib/source/lux/world/net/http/response.lux
index 3bca36449..fc23dfd20 100644
--- a/stdlib/source/lux/world/net/http/response.lux
+++ b/stdlib/source/lux/world/net/http/response.lux
@@ -1,5 +1,8 @@
(.module:
[lux #*
+ [control
+ [concurrency
+ ["." frp ("channel/." Monad<Channel>)]]]
[data
["." text
format
@@ -8,8 +11,6 @@
["." array]
["." dictionary (#+ Dictionary)]]]
["." io]
- [concurrency
- ["." frp ("channel/." Monad<Channel>)]]
[world
["." binary (#+ Binary)]]]
["." // (#+ Body Response)
@@ -43,3 +44,12 @@
(header.content-length (binary.size data))
(header.content-type mime.text))
#//.body (channel/wrap data)}]))
+
+(def: #export (text content)
+ (-> Text Response)
+ (let [data (encoding.to-utf8 content)]
+ [status.ok
+ {#//.headers (|> (dictionary.new text.Hash<Text>)
+ (header.content-length (binary.size data))
+ (header.content-type mime.text))
+ #//.body (channel/wrap data)}]))