Commit d6e42e0c authored by Z.J. van de Weg's avatar Z.J. van de Weg

GrapeDSL for Namespace endpoint

parent 4be63f5b
...@@ -4,20 +4,18 @@ module API ...@@ -4,20 +4,18 @@ module API
before { authenticate! } before { authenticate! }
resource :namespaces do resource :namespaces do
# Get a namespaces list desc 'Get a namespaces list' do
# success Entities::Namespace
# Example Request: end
# GET /namespaces params do
get do optional :search, type: String, desc: "Search query for namespaces"
@namespaces = if current_user.admin
Namespace.all
else
current_user.namespaces
end end
@namespaces = @namespaces.search(params[:search]) if params[:search].present? get do
@namespaces = paginate @namespaces namespaces = current_user.admin ? Namespace.all : current_user.namespaces
namespaces = namespaces.search(params[:search]) if params[:search].present?
present @namespaces, with: Entities::Namespace present paginate(namespaces), with: Entities::Namespace
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment