Implement REST API #1

Open
opened 2019-03-07 13:45:54 +01:00 by blallo · 2 comments
Owner

We need an HTTP APIs to interact with remote agents (for example a webapp or an app).

The design proposal is:

  • POST /auth params username and password
    To get an authentication cookie. The cookie should be bound to the /<username> path and have a sensible expiration time (600s?)
  • GET /<username>/status
    Should answer a serialized data structure with the relevant info encoded (json).
    Should give back 403 if no or invalid auth cookie is provided by the client.
  • POST /<username>/checkin
    POST /<username>/checkout
    Should answer 200 and a json object with at least the result key. The possible values can be success, failed, timeout.
    Should give back 403 if no or invalid auth cookie is provided by the client.

The possible implementation could be Flask or aiohttp.

We need an HTTP APIs to interact with remote agents (for example a webapp or an app). The design proposal is: - `POST /auth` params `username` and `password` To get an authentication cookie. The cookie should be bound to the `/<username>` path and have a sensible expiration time (600s?) - `GET /<username>/status` Should answer a serialized data structure with the relevant info encoded (json). Should give back 403 if no or invalid auth cookie is provided by the client. - `POST /<username>/checkin` `POST /<username>/checkout` Should answer 200 and a json object with at least the `result` key. The possible values can be `success`, `failed`, `timeout`. Should give back 403 if no or invalid auth cookie is provided by the client. The possible implementation could be `Flask` or `aiohttp`.
blallo self-assigned this 2019-03-07 13:45:54 +01:00
Collaborator

What do you thin about FastApi?

What do you thin about [FastApi](https://fastapi.tiangolo.com/)?
Author
Owner

Nice! I didn't know it. The truth is that I wanted to learn asyncio and aiohttp.

If you take a look at the Starlette code (that underlies FasApi) you will find something similar to what I did:

Nice! I didn't know it. The truth is that I wanted to learn `asyncio` and `aiohttp`. If you take a look at the Starlette code (that underlies FasApi) you will find something similar to what I did: - https://github.com/encode/starlette/blob/master/starlette/concurrency.py#L25 - https://git.abbiamoundominio.org/blallo/BotZ/src/branch/master/bot_z/async_operator.py#L30
Sign in to join this conversation.
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blallo/BotZ#1
No description provided.