Sha256: ed694a8b643b4e85fd0aee493701749bad8eecf8f5f950f5a9af3474a60df89a
Contents?: true
Size: 728 Bytes
Versions: 6
Compression:
Stored size: 728 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) error!({ message: "IP:#{ip} is not found" }, 404) if data.nil? present data, with: Entities::IPAddress end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems