Sha256: 841a50541b74e1899611504956c6bba5585c36268a8bf5fd7c3d9d4540d4d268

Contents?: true

Size: 572 Bytes

Versions: 11

Compression:

Stored size: 572 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Controllers
    class TagsController < BaseController
      get "/api/tags" do
        tags = Mihari::Tag.distinct.pluck(:name)
        json tags
      end

      delete "/api/tags/:name" do
        name = params["name"]

        begin
          Mihari::Tag.where(name: name).destroy_all

          status 204
          body ""
        rescue ActiveRecord::RecordNotFound
          status 404

          message = { message: "Name:#{name} is not found" }
          json message
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mihari-3.4.1 lib/mihari/web/controllers/tags_controller.rb
mihari-3.4.0 lib/mihari/web/controllers/tags_controller.rb
mihari-3.3.0 lib/mihari/web/controllers/tags_controller.rb
mihari-3.2.0 lib/mihari/web/controllers/tags_controller.rb
mihari-3.1.0 lib/mihari/web/controllers/tags_controller.rb
mihari-3.0.1 lib/mihari/web/controllers/tags_controller.rb
mihari-3.0.0 lib/mihari/web/controllers/tags_controller.rb
mihari-2.4.0 lib/mihari/web/controllers/tags_controller.rb
mihari-2.3.1 lib/mihari/web/controllers/tags_controller.rb
mihari-2.3.0 lib/mihari/web/controllers/tags_controller.rb
mihari-2.2.1 lib/mihari/web/controllers/tags_controller.rb