Skip to content

Instantly share code, notes, and snippets.

@dahlia
Last active August 29, 2015 14:00
Show Gist options
  • Save dahlia/11075044 to your computer and use it in GitHub Desktop.
Save dahlia/11075044 to your computer and use it in GitHub Desktop.
WANTED LIBRARY

Wanted library

Problems I've spent much time to solve:

  • Web servers. More exactly, API servers that communicate through HTTP.
  • Choosing the right status codes for the situations.
  • Authentication. Fortunately oauthlib solves much of this. Though more efforts are still needed.
  • Writing docs. I made sphinxcontrib-httpdomain to solve this, but it still is not fully automated.
  • Exposing the data models and logical operations to them to HTTP. It has been always repeated by my hand.
  • Writing unit tests. Assert the status code. Assert the response headers. Parse the response JSON. Compare it to the expected one. Repeat.
  • Unit tests for the server test the equivalent logical semantics what unit tests for the model test.

Should the above situations be inherently repeated?

  • ORM already knows much about the model logics. It might be possible to automatically expose to HTTP with some whitlisting.
  • The purposes of HTTP status codes are more clear than we believe.
  • The most messages of the error responses duplicate the docs.

    def login():
        """
        :status 400: when the password is incorrect
        """
        if blah:
            response = jsonify(message='the pasword is incorrect')
            response.status_code = 400
            return response
  • More declarative test codes might be possible to generate both of model tests and server tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment