Skip to content

Document the Middleware type alias#858

Merged
snoyberg merged 1 commit into
yesodweb:masterfrom
Profpatsch:doc-wai-middleware
Oct 22, 2021
Merged

Document the Middleware type alias#858
snoyberg merged 1 commit into
yesodweb:masterfrom
Profpatsch:doc-wai-middleware

Conversation

@Profpatsch

@Profpatsch Profpatsch commented Oct 20, 2021

Copy link
Copy Markdown
Contributor

I tried to come at this from the angle of

  1. A user of Wai trying to understand what Middleware is
    and how to use it, especially what happens if you chain
    multiple middlewares and in what order their are called.

  2. A developer trying to implement new middleware, how to
    modify requests and responses, and how to pass on data.

by giving examples of how the type signatures and
simple usage/implementations look.

I think Wai is a super fundamental module for the Haskell
ecosystem, so we should aim for the documentation to be top
notch (think: rust stdlib).

I think the rest of the module needs a simple overhaul,
but I was especially annoyed by having to reconstruct Middleware
from first principles every time I built a server (“which order
does it chain again?”).

Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

@Profpatsch

Copy link
Copy Markdown
Contributor Author

Please check especially the code examples, I tried most of them in a slightly modified form on the REPL, but I might have typoed something. The examples are not copy-pastable, which would be the gold standard, but I think pseudocode like this already helps a lot in practice.

@Profpatsch

Copy link
Copy Markdown
Contributor Author

Rendered:

screenshot
screenshot
screenshot

@Profpatsch

Copy link
Copy Markdown
Contributor Author

Looks to me like the Windows CI failure is unrelated.

@snoyberg snoyberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, some minor points added

Comment thread wai/Network/Wai.hs Outdated
Comment thread wai/Network/Wai.hs Outdated
I tried to come at this from the angle of

1) A user of Wai trying to understand what `Middleware` is
   and how to use it, especially what happens if you chain
   multiple middlewares and in what order their are called.

2) A developer trying to implement new middleware, how to
   modify requests and responses, and how to pass on data.

by giving examples of how the type signatures and
simple usage/implementations look.

I think `Wai` is a super fundamental module for the Haskell
ecosystem, so we should aim for the documentation to be top
notch (think: rust stdlib).

I think the rest of the module needs a simple overhaul,
but I was especially annoyed by having to reconstruct Middleware
from first principles every time I built a server (“which order
does it chain again?”).
@snoyberg snoyberg merged commit f825a39 into yesodweb:master Oct 22, 2021
@snoyberg

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants