diff options
author | Eduardo Julian | 2022-11-15 14:06:17 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-11-15 14:06:17 -0400 |
commit | d656ef2143151a1d78768df4562e5275dff67b9d (patch) | |
tree | 554f6e64c09654e0faeeed3662183c63c35cf514 /stdlib/source/library/lux/world/net/http | |
parent | 4c765d22bd0a2e5271bf350745ed29f66bfbb96a (diff) |
Added LineNumberTable annotations to functions when compiling for the JVM.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux/world/net/http.lux | 24 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/net/http/request.lux | 85 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/net/http/server.lux | 12 |
3 files changed, 58 insertions, 63 deletions
diff --git a/stdlib/source/library/lux/world/net/http.lux b/stdlib/source/library/lux/world/net/http.lux index d03a8d398..542ddc9ee 100644 --- a/stdlib/source/library/lux/world/net/http.lux +++ b/stdlib/source/library/lux/world/net/http.lux @@ -1,17 +1,12 @@ (.require [library - [lux (.except #version #host) + [lux (.except) [control [try (.only Try)]] [data [binary (.only Binary)]]]] [/ - [version (.only Version)] - [status (.only Status)] - [header (.only Headers)]] - [// (.only Address) - [uri (.only URI) - [scheme (.only Scheme)]]]) + [header (.only Headers)]]) (type .public Method (Variant @@ -29,21 +24,6 @@ (-> (Maybe Nat) (! (Try [Nat Binary])))) -(type .public Identification - (Record - [#local Address - #remote Address])) - -(type .public Protocol - (Record - [#version Version - #scheme Scheme])) - -(type .public Resource - (Record - [#method Method - #uri URI])) - (type .public (Message !) (Record [#headers Headers diff --git a/stdlib/source/library/lux/world/net/http/request.lux b/stdlib/source/library/lux/world/net/http/request.lux index 05b55332a..92f532ba3 100644 --- a/stdlib/source/library/lux/world/net/http/request.lux +++ b/stdlib/source/library/lux/world/net/http/request.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except) + [lux (.except #version) [abstract [monad (.only Monad)]] [control @@ -12,20 +12,35 @@ ["[0]" utf8 (.use "[1]#[0]" codec)]]] [format ["[0]" json (.only JSON) (.use "[1]#[0]" codec)]]]]] - ["[0]" // (.only Body) - ["[0]" version] + ["[0]" // (.only Method Body) + ["[0]" version (.only Version)] ["[0]" header (.only Header)] - ["/[1]" // (.only) + ["/[1]" // (.only Address) ["[0]" mime] [uri (.only URI) - ["[0]" scheme] + ["[0]" scheme (.only Scheme)] ["[0]" query (.only Query) (.use "[1]#[0]" codec)]]]]) +(type .public Identification + (Record + [#local Address + #remote Address])) + +(type .public Protocol + (Record + [#version Version + #scheme Scheme])) + +(type .public Resource + (Record + [#method Method + #uri URI])) + (type .public (Request !) (Record - [#identification //.Identification - #protocol //.Protocol - #resource //.Resource + [#identification Identification + #protocol Protocol + #resource Resource #message (//.Message !)])) (def (body ! it) @@ -39,14 +54,14 @@ (All (_ !) (-> (Monad !) Text (Request !))) - [#identification [//.#local [///.#host "" - ///.#port 0] - //.#remote [///.#host "" - ///.#port 0]] - #protocol [//.#version version.v1_1 - //.#scheme scheme.http] - #resource [//.#method {//.#Post} - //.#uri ""] + [#identification [#local [///.#host "" + ///.#port 0] + #remote [///.#host "" + ///.#port 0]] + #protocol [#version version.v1_1 + #scheme scheme.http] + #resource [#method {//.#Post} + #uri ""] #message [//.#headers (|> header.empty (header.has header.content_type mime.utf_8)) //.#body (body ! (utf8#encoded it))]]) @@ -57,14 +72,14 @@ (All (_ !) (-> (Monad !) JSON (Request !))) - [#identification [//.#local [///.#host "" - ///.#port 0] - //.#remote [///.#host "" - ///.#port 0]] - #protocol [//.#version version.v1_1 - //.#scheme scheme.http] - #resource [//.#method {//.#Post} - //.#uri ""] + [#identification [#local [///.#host "" + ///.#port 0] + #remote [///.#host "" + ///.#port 0]] + #protocol [#version version.v1_1 + #scheme scheme.http] + #resource [#method {//.#Post} + #uri ""] #message [//.#headers (|> header.empty (header.has header.content_type mime.json)) //.#body (body ! (utf8#encoded (json#encoded it)))]]) @@ -73,14 +88,14 @@ (All (_ !) (-> (Monad !) Query (Request !))) - [#identification [//.#local [///.#host "" - ///.#port 0] - //.#remote [///.#host "" - ///.#port 0]] - #protocol [//.#version version.v1_1 - //.#scheme scheme.http] - #resource [//.#method {//.#Post} - //.#uri ""] + [#identification [#local [///.#host "" + ///.#port 0] + #remote [///.#host "" + ///.#port 0]] + #protocol [#version version.v1_1 + #scheme scheme.http] + #resource [#method {//.#Post} + #uri ""] #message [//.#headers (|> header.empty (header.has header.content_type mime.form)) //.#body (body ! (utf8#encoded (query#encoded it)))]]) @@ -90,7 +105,7 @@ (All (_ !) (-> (Request !) (Request !))) - (|>> (has [#protocol //.#scheme] <scheme>)))] + (|>> (has [#protocol #scheme] <scheme>)))] [http scheme.http] [https scheme.https] @@ -101,7 +116,7 @@ (All (_ !) (-> (Request !) (Request !))) - (has [#resource //.#method] {<method>}))] + (has [#resource #method] {<method>}))] [post //.#Post] [get //.#Get] @@ -118,7 +133,7 @@ (All (_ !) (-> URI (Request !) (Request !))) - (|>> (has [#resource //.#uri] it))) + (|>> (has [#resource #uri] it))) (def .public (with_header it value) (All (_ ! of) diff --git a/stdlib/source/library/lux/world/net/http/server.lux b/stdlib/source/library/lux/world/net/http/server.lux index 43c2b7816..a453c944b 100644 --- a/stdlib/source/library/lux/world/net/http/server.lux +++ b/stdlib/source/library/lux/world/net/http/server.lux @@ -45,7 +45,7 @@ (-> (Server !) (Server !))) (function (_ ! request) - (if (scheme#= <scheme> (the [request.#protocol //.#scheme] request)) + (if (scheme#= <scheme> (the [request.#protocol request.#scheme] request)) (server ! request) (at ! in (response.not_found !)))))] @@ -59,7 +59,7 @@ (-> (Server !) (Server !))) (function (_ ! request) - (when (the [request.#resource //.#method] request) + (when (the [request.#resource request.#method] request) {<method>} (server ! request) @@ -82,8 +82,8 @@ (-> URI (Server !) (Server !))) (function (_ ! request) - (if (text.starts_with? path (the [request.#resource //.#uri] request)) - (server ! (revised [request.#resource //.#uri] + (if (text.starts_with? path (the [request.#resource request.#uri] request)) + (server ! (revised [request.#resource request.#uri] (|>> (text.clip_since (text.size path)) maybe.trusted) request)) @@ -129,14 +129,14 @@ (-> (?environment.Parser of) (-> of (Server !)) (Server !))) (function (_ ! request) - (let [full (the [request.#resource //.#uri] request) + (let [full (the [request.#resource request.#uri] request) [uri query] (|> full (text.split_by "?") (maybe.else [full ""]))] (when (do try.monad [query (query#decoded query) input (?environment.result parser query)] - (in [(has [request.#resource //.#uri] uri request) + (in [(has [request.#resource request.#uri] uri request) input])) {try.#Success [request input]} (server input ! request) |