How to use the nameko.web.handlers.http function in nameko

To help you get started, we’ve selected a few nameko 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 nameko / nameko / test / web / test_http_handler.py View on Github external
    @http('GET', '/headers')
    def do_headers(self, request):
        return 201, {'x-foo': 'bar'}, 'created'
github etalab / croquemort / croquemort / http.py View on Github external
    @http('POST', '/check/one')
    @required_parameters('url')
    def check_one(self, data):
        url = data.get('url')
        group = data.get('group')
        callback_url = data.get('callback_url')
        url_hash = generate_hash_for('url', url)
        log('Checking "{url}" ({hash}) in group "{group}"'.format(
            url=url, hash=url_hash, group=group))
        self.fetch(url, group=group, callback_url=callback_url)
        return json.dumps({'url-hash': url_hash}, indent=2)
github etalab / croquemort / croquemort / http.py View on Github external
    @http('GET', '/csv')
    @required_parameters()
    def csv_report(self, data):
        log('CSV report')
        all_urls = self.storage.get_all_urls()
        if not all_urls:
            return 404, ''
        filters, excludes = extract_filters(data)
        return compute_csv(all_urls, filters, excludes)
github PacktPublishing / Python-Programming-Blueprints / Chapter05 / step-9-add-polling / temp_messenger / service.py View on Github external
    @http('GET', '/')
    def home(self, request):
        messages = self.message_service.get_all_messages()
        rendered_template = self.jinja.render_home(messages)
        html_response = create_html_response(rendered_template)

        return html_response
github morganjbruce / microservices-in-action / chapter-7 / chassis / http_demo.py View on Github external
    @http('POST', '/books')
    def demo_post(self, request):
        return Response(json.dumps({'book': request.data.decode()}),
                        mimetype='application/json')
github nameko / nameko / docs / examples / config_dependency_provider.py View on Github external
    @http('GET', '/foo')
    def foo(self, request):
        if not self.foo_enabled:
            return 403, "FeatureNotEnabled"

        return 'foo'
github splunk / eventgen / splunk_eventgen / eventgen_nameko_server.py View on Github external
    @http('POST', '/conf')
    def http_set_conf(self, request):
        data = request.get_data()
        if data:
            return self.set_conf(data)
        else:
            return '400', 'Please pass the valid parameters.'
github splunk / eventgen / splunk_eventgen / eventgen_nameko_server.py View on Github external
    @http('GET', '/conf')
    def http_get_conf(self, request):
        output = self.get_conf()
        if type(output) == str:
            return output
        else:
            return json.dumps(output)
github splunk / eventgen / splunk_eventgen / eventgen_nameko_controller.py View on Github external
    @http('POST', '/start')
    def http_start(self, request):
        return self.start(target="all")
github splunk / eventgen / splunk_eventgen / eventgen_nameko_controller.py View on Github external
    @http('PUT', '/conf')
    def http_edit_conf(self, request):
        data = request.get_data()
        if data:
            self.edit_conf(target="all", data=data)
            return self.http_get_conf(request)
        else:
            return 400, 'Please pass valid config data.'