Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
99 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,38 @@ | ||
open Functoria | ||
open Mirage_impl_conduit_connector | ||
open Mirage_impl_stack | ||
open Mirage_impl_misc | ||
open Mirage_impl_random | ||
|
||
type conduit = Conduit | ||
let conduit = Type Conduit | ||
|
||
let conduit_with_connectors connectors = impl @@ object | ||
let pkg = package ~min:"2.3.0" ~max:"3.0.0" "conduit-mirage" | ||
|
||
let tcp = impl @@ object | ||
inherit base_configurable | ||
method ty = conduit | ||
method name = Functoria_app.Name.create "conduit" ~prefix:"conduit" | ||
method module_name = "Conduit_mirage" | ||
method ty = stackv4 @-> conduit | ||
method name = Functoria_app.Name.create "conduit_tcp" ~prefix:"conduit_tcp" | ||
method module_name = "Conduit_mirage.TCP" | ||
method! packages = Mirage_key.pure [ pkg ] | ||
method! deps = List.map abstract connectors | ||
method! connect _i _ = function | ||
| [ stack ] -> Fmt.strf "Lwt.return %s@;" stack | ||
| _ -> failwith (connect_err "tcp_conduit" 1) | ||
end | ||
|
||
method! connect _i _ connectors = | ||
let pp_connector = Fmt.fmt "%s >>=@ " in | ||
let pp_connectors = Fmt.list ~sep:Fmt.nop pp_connector in | ||
Fmt.strf | ||
"Lwt.return Conduit_mirage.empty >>=@ \ | ||
%a\ | ||
fun t -> Lwt.return t" | ||
pp_connectors connectors | ||
let tls random = impl @@ object | ||
inherit base_configurable | ||
method ty = conduit @-> conduit | ||
method name = Functoria_app.Name.create "conduit_tls" ~prefix:"conduit_tls" | ||
method module_name = "Conduit_mirage.TLS" | ||
method! deps = [ abstract random ] | ||
method! packages = | ||
Mirage_key.pure [ | ||
package ~min:"0.12.0" ~max:"0.13.0" "tls-mirage"; pkg] | ||
method! connect _i _ = function | ||
| [ stack; _random ] -> Fmt.strf "Lwt.return %s@;" stack | ||
| _ -> failwith (connect_err "tls_conduit" 1) | ||
end | ||
|
||
let conduit_direct ?(tls=false) s = | ||
(* TCP must be before tls in the list. *) | ||
let connectors = [tcp_conduit_connector $ s] in | ||
let connectors = | ||
if tls then | ||
connectors @ [tls_conduit_connector] | ||
else | ||
connectors | ||
in | ||
conduit_with_connectors connectors | ||
let conduit_direct ?tls:(use_tls=false) ?(random=default_random) s = | ||
if use_tls then tls random $ (tcp $ s) | ||
else tcp $ s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
open Functoria | ||
|
||
type conduit | ||
|
||
val conduit : conduit Functoria.typ | ||
val pkg : package | ||
|
||
val conduit : conduit typ | ||
|
||
val conduit_direct : | ||
?tls:bool | ||
-> Mirage_impl_stack.stackv4 Functoria.impl | ||
-> conduit Functoria.impl | ||
?tls:bool -> | ||
?random:Mirage_impl_random.random impl | ||
-> Mirage_impl_stack.stackv4 impl | ||
-> conduit impl |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
open Functoria | ||
|
||
type http | ||
|
||
val http : http Functoria.typ | ||
val http : http typ | ||
|
||
val cohttp_server : Mirage_impl_conduit.conduit impl -> http impl | ||
|
||
val httpaf_server : Mirage_impl_conduit.conduit impl -> http impl | ||
|
||
type http_client | ||
|
||
val cohttp_server : | ||
Mirage_impl_conduit.conduit Functoria.impl -> http Functoria.impl | ||
val http_client : http_client typ | ||
|
||
val httpaf_server : | ||
Mirage_impl_conduit.conduit Functoria.impl -> http Functoria.impl | ||
val cohttp_client : | ||
?pclock:Mirage_impl_pclock.pclock impl -> | ||
Mirage_impl_resolver.resolver impl -> | ||
Mirage_impl_conduit.conduit impl -> | ||
http_client impl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters