Skip to content

Commit

Permalink
Add Dream.with_client_stream
Browse files Browse the repository at this point in the history
Primarily useful for the client, so it should be moved to dream-core in
the future. Will also be useful for stream-transforming middlewares.
  • Loading branch information
aantron committed Dec 11, 2021
1 parent ce6c008 commit ed1c949
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/dream.mli
Expand Up @@ -733,6 +733,8 @@ val server_stream : 'a message -> stream
val client_stream : 'a message -> stream
(* TODO Document that this is for middlewares that are transforming a response
stream or a WebSocket. *)
val with_client_stream : stream -> 'a message -> 'a message
(* TODO Normalize with with_stream, or add a separate with_server_stream. *)

(* TODO Probably even close can be made optional. exn can be made optional. *)
(* TODO Argument order? *)
Expand Down
7 changes: 5 additions & 2 deletions src/pure/inmost.ml
Expand Up @@ -298,6 +298,9 @@ let client_stream message =
let server_stream message =
message.server_stream

let with_client_stream client_stream message =
update {message with client_stream}

(* TODO Pending the dream.mli interface reorganization for the new stream
API. *)
let next =
Expand Down Expand Up @@ -499,8 +502,8 @@ let request
upload = initial_multipart_state ();
};
headers;
client_stream = Stream.(stream (string body) no_writer);
server_stream = Stream.(stream no_reader no_writer);
client_stream = Stream.(stream no_reader no_writer);
server_stream = Stream.(stream (string body) no_writer);
locals = Scope.empty;
first = request;
last = ref request;
Expand Down

0 comments on commit ed1c949

Please sign in to comment.