How to use the klein.resource.KleinResource function in klein

To help you get started, we’ve selected a few klein examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Netflix-Skunkworks / stethoscope / tests / test_auth.py View on Github external
def setUp(self):
    super(AppTestCase, self).setUp()

    self.app = klein.Klein()
    self.kr = KleinResource(self.app)

    @self.app.route("/")
    @self.auth.token_required
    def token_required_endpoint(request, userinfo):
      return userinfo
    self.token_required_endpoint = token_required_endpoint

    @self.app.route("/api/")
    @self.auth.match_required
    def match_required_endpoint(request, userinfo, email):
      logger.debug("in endpoint: request={!r}, userinfo={!r}, email={!r}", request, userinfo, email)
      return json.dumps(userinfo)
    self.match_required_endpoint = match_required_endpoint
github twisted / klein / src / klein / app.py View on Github external
def resource(self):
        """
        Return an L{IResource} which suitably wraps this app.

        @returns: An L{IResource}
        """

        return KleinResource(self)
github twisted / klein / src / klein / app.py View on Github external
def resource(self):
        """
        Return an L{IResource} which suitably wraps this app.

        @returns: An L{IResource}
        """

        return KleinResource(self)