Git Product home page Git Product logo

api-builder's People

Contributors

intolerable avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

api-builder's Issues

Support GHC 8.4.3 & Stackage

Good day @intolerable, I've been using your reddit package (which depends on this package) and really want to get it from Stackage, do you have any plan adding these packages to Stackage?

Another problem is that these packages don't compile with GHC 8.4.3 (The only required fix is to add Semigroup instances before Monoid instances), do you have any plan upgrading them?

I can help with everything if you're happy with it.

No query string in POST requests

I had a whole bunch of code for managing API connections that I've almost completely replaced with this library. This is great work.

But I have an issue with the instance instance Sendable (). Because I can't override an instance in Haskell I've basically had to to re-implement a lot of Network.API.Builder.API.

The issue is that it converts all query string parameters into body arguments for a POST request:

  "POST" -> do
    req <- parseUrl $ Text.unpack $ routeURL (_baseURL builder) (_customizeRoute builder r)
    return $ _customizeRequest builder $
      req { requestHeaders = ("Content-Type", "application/x-www-form-urlencoded") : requestHeaders req
          , requestBody = RequestBodyBS (dropQuestion $ queryString req)
          , queryString = ""
          , method = httpMethod r }

Unfortunately one of the APIs I'm working with expects the arguments as a query string. If I need to add body arguments I can always modify the request with _customizeRequest. I've simply re-implemented send like so:

send' :: MonadThrow m => Builder -> Route -> m Request
send' builder r = do
        req <- parseUrl $ unpack $ routeURL (_baseURL builder) (_customizeRoute builder r)
        return $ _customizeRequest builder $ req { method = httpMethod r }

Not really sure if this is an issue you want to fix. This library really simplified some things for me so I figured I'd let you know.

Parse Route from String/URL

It would be nice if one could convert something like

http://api.stackexchange.com/2.2/questions?order=asc&min=1413849600&sort=creation&tagged=frp&site=stackoverflow&filter=*1FDl3RYdSl

into a Route without having to manually parse the URL elements into something like:

questionsRoute = Route { urlPieces = [ "2.2", "questions" ]
                       , urlParams = [ "order" =. ("desc"          :: Text)
                                     , "sort"  =. ("creation"      :: Text)
                                     , "site"  =. ("stackoverflow" :: Text)
                                     , ...                                   ]
                       , httpMethod = "GET" }

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.