/
routes.rb
166 lines (140 loc) · 4.64 KB
/
routes.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
Rails.application.routes.draw do
################################################################################
# Root
root to: 'home#index'
################################################################################
# API
namespace :api do
namespace :v2 do
resources :rubygems, param: :name, only: [], constraints: { name: Patterns::ROUTE_PATTERN } do
resources :versions, param: :number, only: :show, constraints: {
number: /#{Gem::Version::VERSION_PATTERN}(?=\.json\z)|#{Gem::Version::VERSION_PATTERN}/
}
end
end
namespace :v1 do
resource :api_key, only: :show do
put :reset
end
resources :profiles, only: :show
resources :downloads, only: :index do
get :top, on: :collection
get :all, on: :collection
end
constraints id: Patterns::ROUTE_PATTERN, format: /json|yaml/ do
get 'owners/:handle/gems',
to: 'owners#gems',
as: 'owners_gems',
constraints: { handle: Patterns::ROUTE_PATTERN },
format: true
resources :downloads, only: :show, format: true
resources :versions, only: :show, format: true do
member do
get :reverse_dependencies, format: true
get 'latest',
to: 'versions#latest',
as: 'latest',
format: true,
constraints: { format: /json|js/ }
end
resources :downloads,
only: [:index],
controller: 'versions/downloads',
format: true do
collection do
get :search, format: true
end
end
end
end
resources :dependencies,
only: [:index],
format: /marshal|json/,
defaults: { format: 'marshal' }
# for handling preflight request
match '/gems/:id' => "rubygems#show", via: :options
resources :rubygems,
path: 'gems',
only: [:create, :show, :index],
id: Patterns::LAZY_ROUTE_PATTERN,
format: /json|yaml/ do
member do
get :reverse_dependencies
end
collection do
delete :yank, to: "deletions#create"
put :unyank, to: "deletions#destroy"
end
constraints rubygem_id: Patterns::ROUTE_PATTERN do
resource :owners, only: [:show, :create, :destroy]
end
end
resource :activity, only: [], format: /json|yaml/ do
collection do
get :latest
get :just_updated
end
end
resource :search, only: :show
resources :web_hooks, only: [:create, :index] do
collection do
delete :remove
post :fire
end
end
end
end
get '/versions' => 'api/compact_index#versions'
get '/info/:gem_name' => 'api/compact_index#info', as: :info
get '/names' => 'api/compact_index#names'
################################################################################
# API v0
scope to: 'api/deprecated#index' do
get 'api_key'
put 'api_key/reset', to: 'api/deprecated#index'
post 'gems'
get 'gems/:id.json'
scope path: 'gems/:rubygem_id' do
put 'migrate'
post 'migrate'
get 'owners(.:format)'
post 'owners(.:format)'
delete 'owners(.:format)'
end
end
################################################################################
# UI
scope constraints: { format: :html }, defaults: { format: 'html' } do
resource :search, only: :show
resource :dashboard, only: :show, constraints: { format: /html|atom/ }
resources :profiles, only: :show
resource :profile, only: [:edit, :update]
resources :stats, only: :index
resources :rubygems,
only: [:index, :show, :edit, :update],
path: 'gems',
constraints: { id: Patterns::ROUTE_PATTERN, format: /html|atom/ } do
resource :subscription,
only: [:create, :destroy],
constraints: { format: :js },
defaults: { format: :js }
resources :versions, only: [:show, :index]
end
end
################################################################################
# Clearance Overrides
resource :session, only: [:create, :destroy]
resources :passwords, only: [:new, :create]
resources :users, only: [:new, :create] do
resource :password, only: [:create, :edit, :update]
end
################################################################################
# Internal Routes
namespace :internal do
get 'ping' => 'ping#index'
get 'revision' => 'ping#revision'
end
unless Clearance.configuration.allow_sign_up?
get '/sign_up' => 'users#disabled_signup'
end
end