In Mitsuki, you’d usually work abstractions like @QueryParam and RequestBody that handle the details of HTTP requests for you. However, sometimes you need to access the raw request object to read headers, inspect client details, or manage cookies.

This guide shows you how to directly access the underlying starlette.requests.Request object in your controller methods.

The Request Type Hint

The easiest way to get the request object is to add a parameter to your controller method and type-hint it as Request. Mitsuki’s dependency injection system will automatically provide the object for you.

Here’s how you can inject the request to read its properties:

from mitsuki import RestController, GetMapping
from starlette.requests import Request

@RestController("/api")
clas...

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help