Giter Club home page Giter Club logo

Comments (2)

romanb avatar romanb commented on July 22, 2024

Hello,

I assume you've already seen the small sample. This library itself only does routing based on paths, with optional variable capture, which is usually the very first step in routing requests to handlers. Once a handler has been chosen based on the request path, you can perform additional routing / branching based on inspecting the request further. For example, to branch based on the request method, you can simply inspect the Request passed to your handler function, e.g. extending the sample code:

bazHandler p rq k = case parseMethod (requestMethod rq) of
    Right GET -> k $ responseLBS status200 []
                   $ maybe L.empty L.fromStrict (lookup "baz" p)
    _ -> k $ responseLBS status405 [] L.empty

If your needs are basic, this approach can be sufficient. If you are interested in libraries that come with a lot more batteries included, you may be interested in one of scotty, wai-routing (which is built on top of this library) or servant but beware that the latter two employ some advanced features of Haskell's type system and may thus have a steep learning curve if you're just starting out.

from wai-route.

AbrahamAlcaina avatar AbrahamAlcaina commented on July 22, 2024

Thank you @romanb for your advice. I'll investigate wai-routing/Scotty

from wai-route.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.