diff --git a/Services/core.rb b/Services/core.rb index bb4f8fb..c243522 100755 --- a/Services/core.rb +++ b/Services/core.rb @@ -449,6 +449,11 @@ module GxG ::File.expand_path("#{::GxG::SYSTEM.gxg_root()}/#{self.vfs_root()}") end # ### API Support + def publish_route(the_method=:get, path, options={}, &block) + if ::GxG::Services::service_available?(:www) + ::GxG::SERVICES[:www].call_event({:publish_route => {:http_method => the_method, :path => path, :options => options, :code => block}}, ::GxG::DB[:administrator]) + end + end def publish_api() if ::GxG::Services::service_available?(:www) ::GxG::SERVICES[:www].call_event({:publish_api => {:service => self, :path => "/#{@provides.to_s}"}}, ::GxG::DB[:administrator]) diff --git a/Services/www/www.rb b/Services/www/www.rb index ccc6844..f60c734 100644 --- a/Services/www/www.rb +++ b/Services/www/www.rb @@ -297,6 +297,14 @@ www_service.on(:at_stop, {:description => "WWW Stop", :usage => "{ :at_stop => ( # {:result => true} end +www_service.on(:publish_route, {:description => "Publish Route", :usage => "{ :publish_route => {:http_method => :get, :path => '/path', :options => {}, :code => proc}}", :public => false}) do |data, credential| + # Code Usage: + # ::GxG::SERVICES[:core].publish_route(:get,"/",{}) do |the_method,the_request,the_session| + # end + Node0.publish_route(data[:http_method], data[:path], data[:options, &data[:code]) + # + {:result => true} +end www_service.on(:publish_api, {:description => "Publish Service API", :usage => "{ :publish_api => {:service => (service-object), :path => '/path'} }", :public => false}) do |data, credential| # ::GxGwww::publish_api(data[:service], data[:path])