Skip to content

Commit

Permalink
[api] Remove duplicate definition of route constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
poiru authored and coolo committed Jan 11, 2015
1 parent acda5a4 commit d5f2c34
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/api/config/routes.rb
Expand Up @@ -24,12 +24,21 @@ def self.matches?(request)

OBSApi::Application.routes.draw do

constraints(WebuiMatcher) do
cons = {
arch: %r{[^\/]*},
binary: %r{[^\/]*},
filename: %r{[^\/]*},
id: %r{\d*},
login: %r{[^\/]*},
package: %r{[^\/]*},
project: %r{[^\/]*},
repository: %r{[^\/]*},
service: %r{\w[^\/]*},
title: %r{[^\/]*},
user: %r{[^\/]*}
}

cons = {project: %r{[^\/]*}, package: %r{[^\/]*}, binary: %r{[^\/]*},
user: %r{[^\/]*}, login: %r{[^\/]*}, title: %r{[^\/]*}, service: %r{\w[^\/]*},
repository: %r{[^\/]*}, filename: %r{[^\/]*}, arch: %r{[^\/]*},
id: %r{\d*}}
constraints(WebuiMatcher) do

root 'webui/main#index'

Expand Down Expand Up @@ -319,11 +328,6 @@ def self.matches?(request)
end

# first the routes where the mime type does not matter
cons = {project: %r{[^\/]*}, package: %r{[^\/]*},
binary: %r{[^\/]*}, user: %r{[^\/]*}, login: %r{[^\/]*},
title: %r{[^\/]*}, service: %r{\w[^\/]*},
repository: %r{[^\/]*}, filename: %r{[^\/]*},
arch: %r{[^\/]*}, id: %r{\d*}}

### /build
match 'build/:project/:repository/:arch/:package/_status' => 'build#index', constraints: cons, via: [:get, :post]
Expand Down Expand Up @@ -676,7 +680,7 @@ def self.matches?(request)
end

# this can be requested by non browsers (like HA proxies :)
get 'apidocs/:filename' => 'webui/apidocs#file', constraints: {filename: %r{[^\/]*}}, as: 'apidocs_file'
get 'apidocs/:filename' => 'webui/apidocs#file', constraints: cons, as: 'apidocs_file'

# TODO: move to api
# spiders request this, not browsers
Expand Down

0 comments on commit d5f2c34

Please sign in to comment.