sparckles / Robyn

Robyn is a Super Fast Async Python Web Framework with a Rust runtime.
https://robyn.tech/
BSD 2-Clause "Simplified" License
4.44k stars 229 forks source link

feat: split request params #952

Closed VishnuSanal closed 1 month ago

VishnuSanal commented 2 months ago

Description

This PR fixes #850

Summary

This PR does split request params

PR Checklist

Please ensure that:

Pre-Commit Instructions:

vercel[bot] commented 2 months ago

@VishnuSanal is attempting to deploy a commit to the sparckles Team on Vercel.

A member of the Team first needs to authorize it.

VishnuSanal commented 2 months ago

@sansyrox, the tests pass here. can you PTAL at the interface + an initial review, if you will. :)

codspeed-hq[bot] commented 2 months ago

CodSpeed Performance Report

Merging #952 will not alter performance

Comparing VishnuSanal:split-request-params (a057d05) with main (74cdabf)

Summary

✅ 116 untouched benchmarks

🆕 29 new benchmarks

Benchmarks breakdown

Benchmark main VishnuSanal:split-request-params Change
🆕 test_openapi_query_params N/A 6.4 ms N/A
🆕 test_split_request_params_get_body[split_request_typed-async] N/A 4.9 ms N/A
🆕 test_split_request_params_get_body[split_request_typed-sync] N/A 4.9 ms N/A
🆕 test_split_request_params_get_body[split_request_untyped-async] N/A 4.9 ms N/A
🆕 test_split_request_params_get_body[split_request_untyped-sync] N/A 4.9 ms N/A
🆕 test_split_request_params_get_combined[split_request_typed-async] N/A 5.1 ms N/A
🆕 test_split_request_params_get_combined[split_request_typed-sync] N/A 5.1 ms N/A
🆕 test_split_request_params_get_combined[split_request_untyped-async] N/A 5.1 ms N/A
🆕 test_split_request_params_get_combined[split_request_untyped-sync] N/A 5.1 ms N/A
🆕 test_split_request_params_get_combined_failure[async] N/A 5.1 ms N/A
🆕 test_split_request_params_get_combined_failure[sync] N/A 5 ms N/A
🆕 test_split_request_params_get_headers[split_request_typed-async] N/A 4.8 ms N/A
🆕 test_split_request_params_get_headers[split_request_typed-sync] N/A 4.8 ms N/A
🆕 test_split_request_params_get_headers[split_request_untyped-async] N/A 4.8 ms N/A
🆕 test_split_request_params_get_headers[split_request_untyped-sync] N/A 4.8 ms N/A
🆕 test_split_request_params_get_method[split_request_typed-async] N/A 4.8 ms N/A
🆕 test_split_request_params_get_method[split_request_typed-sync] N/A 4.8 ms N/A
🆕 test_split_request_params_get_method[split_request_untyped-async] N/A 4.8 ms N/A
🆕 test_split_request_params_get_method[split_request_untyped-sync] N/A 4.8 ms N/A
🆕 test_split_request_params_get_path_params[split_request_typed-async] N/A 4.9 ms N/A
... ... ... ... ...


:information_source: Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

sansyrox commented 2 months ago

Hey @VishnuSanal 👋

I really like the current implementation. Great job ✨ But I have a few follow ups. I will share them in a few hours

VishnuSanal commented 2 months ago
VishnuSanal commented 2 months ago

todo:

VishnuSanal commented 2 months ago

hi @sansyrox I have updated the docs, PTAL.

sansyrox commented 2 months ago

Hey @VishnuSanal , left a review.

VishnuSanal commented 1 month ago

converting the assignation to types in split req params would look like this (https://github.com/VishnuSanal/Robyn/pull/1)

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
robyn ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2024 11:53pm
VishnuSanal commented 1 month ago
VishnuSanal commented 1 month ago

image

@sansyrox this is the swagger page for the following robyn app.

from typing import Optional

from robyn import Robyn
from robyn.types import Body, QueryParams, JSONResponse

app = Robyn(__file__)

class CreateItemBody(Body):
    name: Optional[str]
    description: str
    price: float
    tax: float

class CreateItemQueryParams(QueryParams):
    _id: int
    desc: Optional[str]

class CreateItemResponse(JSONResponse):
    body: CreateItemBody
    qp: CreateItemQueryParams

@app.post("/upload/file")
def create_item(body_item: CreateItemBody, query: CreateItemQueryParams) -> int:
    print(body_item, query)
    return 200

app.start()
VishnuSanal commented 1 month ago

@sansyrox PTAL :)

sansyrox commented 1 month ago

Hey @VishnuSanal , some more work is needed here. Also , could you have a look at the conflicts?

VishnuSanal commented 1 month ago

why is this not merged yet? 🤔