lib/nephos-server/routing/load.rb in nephos-server-0.1.4 vs lib/nephos-server/routing/load.rb in nephos-server-0.1.5

- old
+ new

@@ -18,25 +18,40 @@ end end end +def route_prefix + @route_prefix ||= [] + File.join(["/"] + @route_prefix) +end + # @params: what [Hash] def get what + what[:url] = File.expand_path File.join(route_prefix, what[:url]) Nephos::Route.check!(what) Nephos::Route.add(what, "GET") end # @params: what [Hash] def post what + what[:url] = File.join(route_prefix, what[:url]) Nephos::Route.check!(what) Nephos::Route.add(what, "POST") end # @params: what [Hash] def put what + what[:url] = File.join(route_prefix, what[:url]) Nephos::Route.check!(what) Nephos::Route.add(what, "PUT") +end + +def resource(name, &block) + @route_prefix ||= [] + @route_prefix << name + block.call + @route_prefix.pop end load 'routes.rb' puts