diff --git a/controllers/agents_controller.rb b/controllers/agents_controller.rb index d547441c..f8ab687a 100644 --- a/controllers/agents_controller.rb +++ b/controllers/agents_controller.rb @@ -1,11 +1,6 @@ class AgentsController < ApplicationController - ## - # Ontology agents - get "/ontologies/:acronym/agents" do - end - - namespace "/agents" do + def agents_routes # Display all agents get do check_last_modified_collection(LinkedData::Models::Agent) @@ -65,27 +60,35 @@ class AgentsController < ApplicationController agent.delete halt 204 end + end - private + private + def create_agent + params ||= @params + acronym = params["id"] + agent = nil + agent = LinkedData::Models::Agent.find(acronym).include(LinkedData::Models::Agent.goo_attrs_to_load(includes_param)).first if acronym - def create_agent - params ||= @params - acronym = params["id"] - agent = nil - agent = LinkedData::Models::Agent.find(acronym).include(LinkedData::Models::Agent.goo_attrs_to_load(includes_param)).first if acronym - - if agent.nil? - agent = instance_from_params(LinkedData::Models::Agent, params) - else - error 400, "Agent exists, please use HTTP PATCH to update" - end + if agent.nil? + agent = instance_from_params(LinkedData::Models::Agent, params) + else + error 400, "Agent exists, please use HTTP PATCH to update" + end - if agent.valid? - agent.save - else - error 400, agent.errors - end - reply 201, agent + if agent.valid? + agent.save + else + error 400, agent.errors end + reply 201, agent + end + + + namespace "/agents" do + agents_routes + end + + namespace "/Agents" do + agents_routes end end \ No newline at end of file