Skip to content

Custom hook to handle mime type interpretation #1829

@JeanJPNM

Description

@JeanJPNM

Is your feature request related to a problem? Please describe.
Possible solution for #1438, better thought of and more maintainable than #1687.

Describe the solution you'd like
A custom hook that lets the user determine how the body of a request/response should be parsed based on its mime type.
The hook receives the mime type or the request/response headers as input and returns a value from an enum, telling the framework how to interpret the body.

Describe alternatives you've considered

  • Two fields in the svelte.config.js file (one for buffer and other for text) that contain a list of regexes that are tested against a mime type to determine how the body should be parsed.
  • Hardcoded list of mime types for body parsing.

How important is this feature to you?
For me is a very important feature since it will enable users to send binary content from endpoints, and let them define specific handling for some mime types such as image/svg+xml.

Additional context
This feature requires svelte kit to make hooks accessible to adapters.
This feature was made considering that #1563 may become a part of the framework hence the use of an enum instead of a boolean.
This feature is also intended to replace #1687.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions