ash-project / ash_json_api

The JSON:API extension for the Ash Framework
https://hexdocs.pm/ash_json_api
MIT License
63 stars 43 forks source link

Allow customization of response status for POST requests #241

Closed Fasp96 closed 1 month ago

Fasp96 commented 1 month ago

Description:

I need to modify the response status code from the default 201 to 200 for a specific POST route. Despite trying to use the modify_conn function, the status code change doesn't seem to take effect.

The current approach is as follows:

json_api do
  type "twilio"

  routes do
    base("/twilio")

    route :post, "/token", :generate_token do
      modify_conn fn conn, subject, result, request ->
        conn
        |> Plug.Conn.put_status(200)
      end
    end
  end
end

Expected Behavior: The response status for the /token POST route should return 200 instead of 201.

Actual Behavior: The response status remains 201, and the modify_conn function does not override it.

zachdaniel commented 1 month ago

Hey @Fasp96, addressed in main, mind trying it out?

Fasp96 commented 1 month ago

It work! 🙌 Thank you @zachdaniel

Fasp96 commented 1 month ago

Just wondering, any idea when the next release will be out? It seems like this is the only change since the last version, so curious if it'll happen soon.

zachdaniel commented 1 month ago

I'll cut one now

Fasp96 commented 1 month ago

Thank you