Files
fizzy/app/controllers/webhooks/activations_controller.rb
Rob Zolkos 0435db30ba Add JSON response format to webhooks (#2671)
* Add JSON response format to webhooks

Support JSON responses for all webhook endpoints: index, show, create,
update, destroy, and activation. Adds jbuilder views, updates controllers
to use respond_to, and documents the API in docs/API.md.

* Address PR review feedback

- Use distinct board ID in API docs webhook example
- Use render "webhooks/show" in activations controller for consistency

* Address PR review feedback from flavorjones

- Include webhook.board in cache key to avoid stale board data
- Use _url instead of _path for location header consistency

* Fix webhook create test to match Location header format

Use board_webhook_url instead of board_webhook_path since the controller
returns a full URL in the Location header.

* Fix board ID in Location header example in API docs

Use distinct board ID in the Location URL to match the JSON body example.
2026-03-09 17:33:30 -04:00

16 lines
360 B
Ruby

class Webhooks::ActivationsController < ApplicationController
include BoardScoped
before_action :ensure_admin
def create
@webhook = @board.webhooks.find(params[:webhook_id])
@webhook.activate
respond_to do |format|
format.html { redirect_to @webhook }
format.json { render "webhooks/show", status: :created }
end
end
end