Class: NewsmastMastodon::Api::V1::UtilitiesController
- Inherits:
-
Api::BaseController
- Object
- Api::BaseController
- NewsmastMastodon::Api::V1::UtilitiesController
- Defined in:
- app/controllers/newsmast_mastodon/api/v1/utilities_controller.rb
Instance Method Summary collapse
Instance Method Details
#link_preview ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/newsmast_mastodon/api/v1/utilities_controller.rb', line 3 def link_preview url = params[:url] unless url.present? return render json: { error: 'URL must be present' }, status: :bad_request end begin data = LinkThumbnailer.generate(url) render json: data, status: :ok rescue LinkThumbnailer::Exceptions => e render json: { error: e. }, status: :unprocessable_entity end end |