Skip to content

Set Content-Type of request body #634

Open
@tialki

Description

@tialki

What is the problem this feature would solve?

  • Set Content-Type of request body

What is the feature you are proposing to solve the problem?

new Elysia()
  .parser('application/json-patch+json', ({ request }) => request.json())
  .patch('/movies', () => {}, {
    body: t.Array(
      t.Union([
        t.Object({
          op: t.Union([t.Literal('test'), t.Literal('replace'), t.Literal('add')], {
            description: 'test | replace',
          }),
          path: t.String(),
          value: t.Any(),
        }),
        t.Object({
          op: t.Literal('remove', {
            description: 'remove',
          }),
          path: t.String(),
        }),
        t.Object({
          op: t.Union([t.Literal('move'), t.Literal('copy')], {
            description: 'move | copy',
          }),
          from: t.String(),
          path: t.String(),
        }),
      ])
    ),
    requestBodyType: 'application/json-patch+json'
  })

What alternatives have you considered?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions