mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 02:39:37 +02:00
Add basic REST API
This commit is contained in:
parent
b934850ba7
commit
dc2270491d
5 changed files with 53 additions and 0 deletions
5
Gemfile
5
Gemfile
|
@ -78,6 +78,11 @@ gem 'whenever', '~> 0.9.4', require: false
|
||||||
# for dates and times
|
# for dates and times
|
||||||
gem 'iso8601', '~> 0.8.2'
|
gem 'iso8601', '~> 0.8.2'
|
||||||
|
|
||||||
|
# for REST API
|
||||||
|
gem 'grape', '~> 0.10.1'
|
||||||
|
|
||||||
|
gem 'hashie_rails', '~> 0.0.1'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
# for inserting dummy data
|
# for inserting dummy data
|
||||||
gem 'activerecord-import', '~> 0.6.0'
|
gem 'activerecord-import', '~> 0.6.0'
|
||||||
|
|
21
Gemfile.lock
21
Gemfile.lock
|
@ -125,6 +125,16 @@ GEM
|
||||||
ruby_parser (~> 3.1, > 3.1.0)
|
ruby_parser (~> 3.1, > 3.1.0)
|
||||||
sexp_processor (~> 4.4)
|
sexp_processor (~> 4.4)
|
||||||
formatador (0.2.5)
|
formatador (0.2.5)
|
||||||
|
grape (0.10.1)
|
||||||
|
activesupport
|
||||||
|
builder
|
||||||
|
hashie (>= 2.1.0)
|
||||||
|
multi_json (>= 1.3.2)
|
||||||
|
multi_xml (>= 0.5.2)
|
||||||
|
rack (>= 1.3.0)
|
||||||
|
rack-accept
|
||||||
|
rack-mount
|
||||||
|
virtus (>= 1.0.0)
|
||||||
guard (2.6.1)
|
guard (2.6.1)
|
||||||
formatador (>= 0.2.4)
|
formatador (>= 0.2.4)
|
||||||
listen (~> 2.7)
|
listen (~> 2.7)
|
||||||
|
@ -144,6 +154,10 @@ GEM
|
||||||
activesupport (>= 4.0.1)
|
activesupport (>= 4.0.1)
|
||||||
haml (>= 3.1, < 5.0)
|
haml (>= 3.1, < 5.0)
|
||||||
railties (>= 4.0.1)
|
railties (>= 4.0.1)
|
||||||
|
hashie (3.3.2)
|
||||||
|
hashie_rails (0.0.1)
|
||||||
|
hashie (>= 3.0)
|
||||||
|
rails (~> 4.0)
|
||||||
highline (1.6.21)
|
highline (1.6.21)
|
||||||
hike (1.2.3)
|
hike (1.2.3)
|
||||||
hitimes (1.2.2)
|
hitimes (1.2.2)
|
||||||
|
@ -183,6 +197,7 @@ GEM
|
||||||
mini_portile (0.6.0)
|
mini_portile (0.6.0)
|
||||||
minitest (5.5.0)
|
minitest (5.5.0)
|
||||||
multi_json (1.10.1)
|
multi_json (1.10.1)
|
||||||
|
multi_xml (0.5.5)
|
||||||
nokogiri (1.6.2.1)
|
nokogiri (1.6.2.1)
|
||||||
mini_portile (= 0.6.0)
|
mini_portile (= 0.6.0)
|
||||||
nprogress-rails (0.1.3.1)
|
nprogress-rails (0.1.3.1)
|
||||||
|
@ -212,6 +227,10 @@ GEM
|
||||||
method_source (~> 0.8.1)
|
method_source (~> 0.8.1)
|
||||||
slop (~> 3.4)
|
slop (~> 3.4)
|
||||||
rack (1.5.2)
|
rack (1.5.2)
|
||||||
|
rack-accept (0.4.5)
|
||||||
|
rack (>= 0.4)
|
||||||
|
rack-mount (0.8.3)
|
||||||
|
rack (>= 1.0.0)
|
||||||
rack-test (0.6.2)
|
rack-test (0.6.2)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
railroady (1.2.0)
|
railroady (1.2.0)
|
||||||
|
@ -391,10 +410,12 @@ DEPENDENCIES
|
||||||
epp-xml (~> 0.10.3)
|
epp-xml (~> 0.10.3)
|
||||||
fabrication (~> 2.11.3)
|
fabrication (~> 2.11.3)
|
||||||
faker (~> 1.3.0)
|
faker (~> 1.3.0)
|
||||||
|
grape (~> 0.10.1)
|
||||||
guard (~> 2.6.1)
|
guard (~> 2.6.1)
|
||||||
guard-rspec (~> 4.3.1)
|
guard-rspec (~> 4.3.1)
|
||||||
guard-rubocop (~> 1.1.0)
|
guard-rubocop (~> 1.1.0)
|
||||||
haml-rails (~> 0.5.3)
|
haml-rails (~> 0.5.3)
|
||||||
|
hashie_rails (~> 0.0.1)
|
||||||
isikukood
|
isikukood
|
||||||
iso8601 (~> 0.8.2)
|
iso8601 (~> 0.8.2)
|
||||||
jbuilder (~> 2.0)
|
jbuilder (~> 2.0)
|
||||||
|
|
22
app/api/repp/api.rb
Normal file
22
app/api/repp/api.rb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
module Repp
|
||||||
|
class API < Grape::API
|
||||||
|
format :json
|
||||||
|
prefix :repp
|
||||||
|
version 'v1', using: :path
|
||||||
|
|
||||||
|
http_basic do |username, password|
|
||||||
|
@current_user ||= EppUser.find_by(username: username, password: password)
|
||||||
|
end
|
||||||
|
|
||||||
|
helpers do
|
||||||
|
attr_reader :current_user
|
||||||
|
end
|
||||||
|
|
||||||
|
resource :domains do
|
||||||
|
desc 'Return list of domains'
|
||||||
|
get '/' do
|
||||||
|
current_user.registrar.domains
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -27,6 +27,9 @@ module Registry
|
||||||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
||||||
# config.i18n.default_locale = :de
|
# config.i18n.default_locale = :de
|
||||||
|
|
||||||
|
config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
|
||||||
|
config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
|
||||||
|
|
||||||
config.generators do |g|
|
config.generators do |g|
|
||||||
g.stylesheets false
|
g.stylesheets false
|
||||||
g.javascripts false
|
g.javascripts false
|
||||||
|
|
|
@ -5,6 +5,8 @@ Rails.application.routes.draw do
|
||||||
get 'error/:command', to: 'errors#error', defaults: { format: :xml }
|
get 'error/:command', to: 'errors#error', defaults: { format: :xml }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mount Repp::API => '/'
|
||||||
|
|
||||||
## ADMIN ROUTES
|
## ADMIN ROUTES
|
||||||
namespace(:admin) do
|
namespace(:admin) do
|
||||||
resources :keyrelays
|
resources :keyrelays
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue