Code Monkey home page Code Monkey logo

servant-uverb's Introduction

servant-uverb

Hackage AGPL-3 license Stackage Lts Stackage Nightly Build status

Multiple response statuses and bodies per route for servant.

This set of packages allows you to write servant code for end-points whose response types are open unions of types (UVerb is short for UnionVerb). It should be merged into the resp. servant packages at some point in the future, but mostly for the sake of making it easier to maintan it; it's ready to be used now.

Take a look at ./example/Main.hs to get an idea how it works.

TODO

  • UStream (like Stream)
  • NoContentUVerb (like NoContentVerb)
  • Tests
  • make ./example a self-contained package.
  • convert this list into issues.

Related work

There is an issue from 2017 discussing handlers that return different types under different circumstances.

servant-checked-exceptions is a good solution to the problem, but it restricts the user to JSON and a very specific envelop encoding for the union type, which is often not acceptable. (One good reason for this design choice is that it makes writing clients easier, where you need to get to the union type from one representative, and you don't want to run several parsers in the hope that the ones that should will always error out so you can try until the right one returns a value.)

servnat-exceptions is another shot at at the problem. It is inspired by servant-checked-exceptions, so it may be worth taking a closer look. The README also claims that cardano-sl also has some code for generalized error handling.

We have copied some code from world-peace. The package itself wasn't flexible enough, and we had to use sop-core to implement servant-uverb-server.

Also: https://lukwagoallan.com/posts/unifying-servant-server-error-responses

servant-uverb's People

Contributors

fisx avatar

Watchers

 avatar  avatar

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.