Skip to content

Add to_dict method for request headers #1099

@antonpetrov145

Description

@antonpetrov145

Hello, first of all thank you for this marvelous framework, it is really enjoyable to work with especially as I'm coming from Flask.

I noticed that there are methods for returning dictionaries for query parameters, path parameters and form data are also dictionaries. Suggestion is because currently we are losing the ability to set a default value if the header is missing, if it is - we get always None, but what if we need to have some default value?

My idea is to have something like this

request.headers.to_dict()

which will return a dictionary with all present headers

{
    "content-type": "application/json",
    "X-Forwarded-To": "some IP",
    ...
}

Is this possible to achieve?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions