Sha256: 7edb786f3bee86f63355b47680f3040d8a661a1b4d13532a23463fede35a1703

Contents?: true

Size: 444 Bytes

Versions: 6

Compression:

Stored size: 444 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Controllers
    class IPAddressController < BaseController
      get "/api/ip_addresses/:ip" do
        param :ip, String, required: true

        ip = params["ip"].to_s

        data = Enrichers::IPInfo.query(ip)
        if data.nil?
          status 404
          json({ message: "IP:#{ip} is not found" })
        else
          json data.to_hash
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mihari-3.9.0 lib/mihari/web/controllers/ip_address_controller.rb
mihari-3.8.1 lib/mihari/web/controllers/ip_address_controller.rb
mihari-3.8.0 lib/mihari/web/controllers/ip_address_controller.rb
mihari-3.7.2 lib/mihari/web/controllers/ip_address_controller.rb
mihari-3.7.1 lib/mihari/web/controllers/ip_address_controller.rb
mihari-3.7.0 lib/mihari/web/controllers/ip_address_controller.rb