Skip to content

docs: add comprehensive response return styles reference#1357

Merged
sansyrox merged 1 commit intomainfrom
docs/response-return-styles
Mar 27, 2026
Merged

docs: add comprehensive response return styles reference#1357
sansyrox merged 1 commit intomainfrom
docs/response-return-styles

Conversation

@sansyrox
Copy link
Copy Markdown
Member

@sansyrox sansyrox commented Mar 27, 2026

Summary

  • Adds a new dedicated documentation page covering all 10 supported response return styles in Robyn
  • Each style includes Content-Type, code examples, and caveats
  • Covers: string, dict/list, Response object, bytes, Pydantic models, tuples, FileResponse, html(), StreamingResponse, and SSEResponse
  • Adds navigation entry in the API Reference section

Closes #769

Test plan

  • Verify the new page renders correctly at /documentation/en/api_reference/response-objects
  • Verify navigation link appears in the sidebar under API Reference
  • Verify all code examples are syntactically correct

Made with Cursor

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive API Reference page describing all supported response return styles for route handlers: plain text, JSON, custom response objects, binary payloads, file/HTML helpers, streaming responses, and Server-Sent Events, with examples and guidance.
    • Updated site navigation to include the new Response Objects page and added English and Chinese link titles for localized display.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
robyn Ready Ready Preview, Comment Mar 27, 2026 0:54am

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 63db5078-833c-4ad5-ae25-26a803c9504e

📥 Commits

Reviewing files that changed from the base of the PR and between 69c61a4 and 0106bec.

📒 Files selected for processing (2)
  • docs_src/src/components/documentation/Navigation.jsx
  • docs_src/src/pages/documentation/en/api_reference/response-objects.mdx
✅ Files skipped from review due to trivial changes (2)
  • docs_src/src/components/documentation/Navigation.jsx
  • docs_src/src/pages/documentation/en/api_reference/response-objects.mdx

📝 Walkthrough

Walkthrough

Added a new documentation page detailing Robyn's supported response return styles — plain strings, JSON, Response objects, binary data, Pydantic models, tuples, file helpers, streaming, and SSE — and wired a localized "Response Objects" link into the API Reference navigation.

Changes

Cohort / File(s) Summary
Navigation Integration
docs_src/src/components/documentation/Navigation.jsx
Added a Response Objects link under the API Reference group and extended translations for English and Chinese ('Response Objects' / '响应对象').
Documentation Content
docs_src/src/pages/documentation/en/api_reference/response-objects.mdx
New detailed reference page describing all supported handler return formats (strings, JSON, Response, bytes, Pydantic BaseModel, (body, headers, status) tuples), file/HTML helpers, streaming responses, and SSE with examples and notes. Also exports a description constant.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped to write a doc so clear,
Responses from tiny to grand appear.
Strings, streams, and JSON delight,
Headers, files, and SSE in sight.
Hooray — the docs now sparkle bright! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely summarizes the main change: adding comprehensive documentation on response return styles.
Description check ✅ Passed The PR description is mostly complete, covering summary, test plan, and issue closure. However, it deviates from the template by missing explicit checklist items and pre-commit instructions.
Linked Issues check ✅ Passed The PR fully addresses issue #769 by providing comprehensive documentation on all 10 supported response return styles with examples and guidance.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #769: new documentation page and navigation entry for response return styles are the only modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/response-return-styles

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs_src/src/pages/documentation/en/api_reference/response-objects.mdx`:
- Around line 158-180: The CodeGroup metadata (title/tag/label) is misleading —
it says "POST /create" but the examples are for the not_found and create_user
endpoints; update the CodeGroup header to reflect the actual snippets (e.g.,
change tag/label to something like "Response examples" or "/not-found, /users"
or remove the specific POST /create label) so the CodeGroup matches the two
examples shown (functions not_found and create_user).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 23933e7d-b771-4f69-881f-439a3d2eb485

📥 Commits

Reviewing files that changed from the base of the PR and between 9e1fd74 and 69c61a4.

📒 Files selected for processing (2)
  • docs_src/src/components/documentation/Navigation.jsx
  • docs_src/src/pages/documentation/en/api_reference/response-objects.mdx

Comment on lines +158 to +180
<CodeGroup title="Response" tag="POST" label="/create">

```python {{ title: 'Error response' }}
from robyn import Headers

@app.get("/not-found")
def not_found():
return (
{"error": "Resource not found"},
Headers({"X-Error": "true"}),
404,
)
```

```python {{ title: 'Created response' }}
@app.post("/users")
def create_user():
return (
{"id": 1, "name": "Alice"},
Headers({}),
201,
)
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Align tuple example CodeGroup metadata with the actual examples.

The CodeGroup header currently says POST /create, but the snippets demonstrate GET /not-found and POST /users. This is slightly misleading in rendered docs.

🛠️ Suggested doc fix
-<CodeGroup title="Response" tag="POST" label="/create">
+<CodeGroup title="Response" tag="EXAMPLES" label="Tuple responses">
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs_src/src/pages/documentation/en/api_reference/response-objects.mdx`
around lines 158 - 180, The CodeGroup metadata (title/tag/label) is misleading —
it says "POST /create" but the examples are for the not_found and create_user
endpoints; update the CodeGroup header to reflect the actual snippets (e.g.,
change tag/label to something like "Response examples" or "/not-found, /users"
or remove the specific POST /create label) so the CodeGroup matches the two
examples shown (functions not_found and create_user).

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 27, 2026

Merging this PR will not alter performance

✅ 189 untouched benchmarks


Comparing docs/response-return-styles (0106bec) with main (9e1fd74)

Open in CodSpeed

@sansyrox sansyrox merged commit 7c9d1c4 into main Mar 27, 2026
38 of 41 checks passed
@sansyrox sansyrox deleted the docs/response-return-styles branch March 27, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add docs for different styles of returning response objects

1 participant