Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make server response type abstract and allow streaming in cohttp-eio #1024

Merged
merged 3 commits into from
May 30, 2024

Commits on May 20, 2024

  1. Make server response type abstract

    This will allow cohttp-eio to use a different type in future, which
    should make streaming easier.
    talex5 committed May 20, 2024
    Configuration menu
    Copy the full SHA
    8d9a39d View commit details
    Browse the repository at this point in the history
  2. cohttp-eio: Refactor code a bit

    Makes next commit easier to read:
    
    - Use `respond` helpers in example. Avoids it having to change.
    - Remove useless `IO.t` and `>>=`.
    - Move some functions later in the file, and they'll need to use
      `write`.
    talex5 committed May 20, 2024
    Configuration menu
    Copy the full SHA
    0853c71 View commit details
    Browse the repository at this point in the history
  3. cohttp-eio: Allow streaming responses from handler

    This changes the response type to `writer -> unit`. This allows
    handlers to write the response inside the function, rather than
    returning a request to cohttp to write it later. That's useful because
    it allows e.g. streaming from an open file and then closing it
    afterwards.
    
    Partial application means that code using `respond_string` etc will
    continue to work as before.
    
    This also exposes a more polymorphic version of the `respond` function
    that accepts sub-types of `Flow.source`, so that callers don't need to
    cast the body.
    talex5 committed May 20, 2024
    Configuration menu
    Copy the full SHA
    ba3250b View commit details
    Browse the repository at this point in the history