File tree 3 files changed +14
-1
lines changed
3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,14 @@ request :: forall eff. Options RequestOptions -> (Response -> Eff (http :: HTTP
101
101
102
102
Make a HTTP request using the specified options and response callback.
103
103
104
+ #### ` requestFromURI `
105
+
106
+ ``` purescript
107
+ requestFromURI :: forall eff. String -> (Response -> Eff (http :: HTTP | eff) Unit) -> Eff (http :: HTTP | eff) Request
108
+ ```
109
+
110
+ Make a HTTP request from a URI string and response callback.
111
+
104
112
#### ` requestAsStream `
105
113
106
114
``` purescript
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ module Node.HTTP.Client
13
13
, headers
14
14
, auth
15
15
, request
16
+ , requestFromURI
16
17
, requestAsStream
17
18
, responseAsStream
18
19
, httpVersion
@@ -83,6 +84,10 @@ foreign import requestImpl :: forall eff. Foreign -> (Response -> Eff (http :: H
83
84
request :: forall eff . Options RequestOptions -> (Response -> Eff (http :: HTTP | eff ) Unit ) -> Eff (http :: HTTP | eff ) Request
84
85
request = requestImpl <<< options
85
86
87
+ -- | Make a HTTP request from a URI string and response callback.
88
+ requestFromURI :: forall eff . String -> (Response -> Eff (http :: HTTP | eff ) Unit ) -> Eff (http :: HTTP | eff ) Request
89
+ requestFromURI = requestImpl <<< toForeign
90
+
86
91
-- | Create a writable stream from a request object.
87
92
requestAsStream :: forall eff r a . Request -> Writable r (http :: HTTP | eff ) a
88
93
requestAsStream = unsafeCoerce
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ main = do
18
18
server <- createServer respond
19
19
listen server 8080 $ void do
20
20
log " Listening on port 8080."
21
- req <- Client .request ( Client .hostname := " localhost" <> Client .port := 8080 ) \response -> void do
21
+ req <- Client .requestFromURI " http:// localhost: 8080/ " \response -> void do
22
22
log " Response from GET /:"
23
23
let responseStream = Client .responseAsStream response
24
24
pipe responseStream stdout
You can’t perform that action at this time.
0 commit comments