Skip to main content

Http to thrift protocol conversion

Project description

https://travis-ci.org/elemepi/takumi-http.svg?branch=master

Write http service as a thrift service.

This package implements a protocol transformer from http to thrift. Just write the service as a normal Takumi thrift service, then serve the service as a http service. The developers don’t have to care about the details of the protocol transformation, only add the config thrift_protocol_class to app.yaml and your service can be served as a http service.

Config

thrift_protocol_class: takumi_http.HttpProtocol

Settings

Session related settings:

  • SECRET_KEY (required) secret key for encrypting cookies.

  • PERMANENT_SESSION_LIFETIME timedelta of session lifetime, default 31 day.

  • SESSION_COOKIE_DOMAIN cookie domain.

  • SESSION_COOKIE_PATH cookie path, default ‘/’.

The attributes session_cookie_domain and session_cookie_path can be setted to api context to override default settings.

Example

from takumi import Takumi

app = Takumi('PingService')
app.use(save_session)

@app.api_with_ctx
@pass_request
def say_hello(request, name):
    request.session['user_id'] = 90
    return 'Hello ' + name

Serve the App

Using takumi-cli to the serve the app.

$ takumi serve

Invoke Api

The http method is not very important. If the api has arguments use POST, if not use GET.

Use a http client to invoke api:

$ curl -XPOST http://localhost:1993/say_hello -d '{"name":"world"}'

API URL has this format:

http://<domain>:<port>/<arbitrary>/<api_name>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

takumi_http-0.1.7.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

takumi_http-0.1.7-py2.py3-none-any.whl (13.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file takumi_http-0.1.7.tar.gz.

File metadata

  • Download URL: takumi_http-0.1.7.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.1

File hashes

Hashes for takumi_http-0.1.7.tar.gz
Algorithm Hash digest
SHA256 d63651f0853ec5194cbfb2d91aef64b138ede433d685ef2e6694cac0af963ae0
MD5 e47336cef280adb2156c5b61f97dc258
BLAKE2b-256 2a1fbbb2b516d1f1320eb841c202220f46a891d4d5a8e967af0d4e07c5a48493

See more details on using hashes here.

File details

Details for the file takumi_http-0.1.7-py2.py3-none-any.whl.

File metadata

  • Download URL: takumi_http-0.1.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.1

File hashes

Hashes for takumi_http-0.1.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cfdc510735f744f280deec99f587e8afbbc4e01b7cb9aaa8562860063a46d61b
MD5 a164f3d597b0922d0096f3103c7e7cd8
BLAKE2b-256 86e019c64ea15166f51adc49b5b5e59fcad17d95d55a807561a2c14aae9b40d9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page