Sha256: 1d5eb7e75b149be343193bc4e4b96692631b628b7ef82a6038da00bfb9d65d73

Contents?: true

Size: 770 Bytes

Versions: 43

Compression:

Stored size: 770 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Endpoints
    class IPAddresses < Grape::API
      namespace :ip_addresses do
        desc "Get an IP address", {
          success: Entities::IPAddress,
          failure: [{ code: 404, message: "Not found", model: Entities::Message }],
          summary: "Get an IP address"
        }
        params do
          requires :ip, type: String, regexp: /\A[0-9.]+\z/
        end
        get "/:ip", requirements: { ip: %r{[^/]+} } do
          ip = params[:ip].to_s

          data = Enrichers::IPInfo.query(ip)
          if data.nil?
            error!({ message: "IP:#{ip} is not found" }, 404)
          else
            present data, with: Entities::IPAddress
          end
        end
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
mihari-5.4.3 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.4.2 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.4.1 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.4.0 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.3.2 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.3.1 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.3.0 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.2.4 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.2.3 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.2.2 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.2.1 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.2.0 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.1.4 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.1.3 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.1.2 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.1.1 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.1.0 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.0.1 lib/mihari/web/endpoints/ip_addresses.rb
mihari-5.0.0 lib/mihari/web/endpoints/ip_addresses.rb
mihari-4.12.0 lib/mihari/web/endpoints/ip_addresses.rb