Skip to content

How to set default response content-type? #12

Open
@roydekleijn

Description

@roydekleijn

Hello,

I'm using response()->preferredFormat() . Sometimes I like to get xml or json, depending on the Accept header.

If I don't set the Accept header, my API will return JSON (which is fine) However the content-type isn't set in that case.

How can I set the default content-type to application/json in case I didn't provide the Accept header?

I think we can set it to JSON here:

return $this->json($data, $status, array_merge($headers, ['Content-Type' => $request->headers->get('Accept')]));

Roy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions