Sha256: 8717b7fb03ca843d11814183b271df782bbe5e5366f241647b49b7d843f654a0

Contents?: true

Size: 622 Bytes

Versions: 9

Compression:

Stored size: 622 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
        param :name, String, required: true

        name = params["name"].to_s

        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

9 entries across 9 versions & 1 rubygems

Version Path
mihari-3.9.0 lib/mihari/web/controllers/tags_controller.rb
mihari-3.8.1 lib/mihari/web/controllers/tags_controller.rb
mihari-3.8.0 lib/mihari/web/controllers/tags_controller.rb
mihari-3.7.2 lib/mihari/web/controllers/tags_controller.rb
mihari-3.7.1 lib/mihari/web/controllers/tags_controller.rb
mihari-3.7.0 lib/mihari/web/controllers/tags_controller.rb
mihari-3.6.1 lib/mihari/web/controllers/tags_controller.rb
mihari-3.6.0 lib/mihari/web/controllers/tags_controller.rb
mihari-3.5.0 lib/mihari/web/controllers/tags_controller.rb