Skip to content

Comment on Okapi – A micro web framework for Haskell

Comments

The way this does routing leads to quite hard to read code, compare https://www.okapi.wiki/docs/todo-app:

    todoAPI conn = getTodo conn <|> getAllTodos conn
with
    getTodo conn = do
      methodGET
      pathParam @Text `is` "todos"
      todoID <- pathParam @Int
      ...
so you need to keep in mind both the order of the alternatives in todoAPI as well as the bodies of the individual handlers. That gets unwieldy very quickly.

It also seems likely to lead to the same problems with error handling that you tend to get with combinator parsers, where you usually only get details about the last failing branch, while the interesting failure might have been an earlier one.

Quiz question (I don't know the answer): What happens to a request for /todos/foo?

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.