Giter Club home page Giter Club logo

httpact's People

Contributors

zblanco avatar

Watchers

 avatar

Forkers

cody-demartin

httpact's Issues

Protocol Implementation

Trial runs of the minimal dependency injection capabilities with HTTPact worked, but some common patterns emerged that we can abstract out further. The first is the to_request and from_response functions used to map between HTTPact structs and the API Resource structs.

To enforce and encapsulate these mapping functions I think the next step is to implement a protocol. In the gist HTTPact is based off of, he describes an Operation protocol that covers both to_request and from_response, however I'm thinking two separate protocols for Commands (to_request) and Entities (from_response) will support more flexibility and encourage this declarative approach. Naming may change, but Commands and Entities is pretty good.

This allows API Wrapper libraries be side-effect free by returning protocol enforced data structures which can be passed into HTTPact with a client/adapter. An API Wrapper library might also provide defaults and side-effect executing functions as a convenience, but the protocols make it easier to have this pure-impure separation by default.

We can take this further and simplify our Request structs by taking the :http_client out and instead making that a data-structure which includes the adapter and middleware type support. This will change the execute API to dispatch the data-structure protocol for conversions but also lets us include Authentication details in our client structure that our protocols can dispatch with.

Test Utilities

There are two main consumers for HTTPact:

  • API Wrapper libraries
  • HTTP Client implementations

As such these are the two points where some testing utilities would be helpful.

For API Wrapper libraries we'd likely want an easy way to build a valid HTTP Client that returns expected responses. This way the API Wrapper library can test their error handling and entity conversion properties.

For HTTP Client implementations we might need to go further and build a web server with similar controls for expected responses although with a focus on generic HTTP behavior. Likely a solution a long the lines of Bypass.

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.