Sha256: c1f2eb384ff0c1bd199d98349b27f8fb9dbbe61e4316edb4f8bdf2352655571f
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
module Galago class Router class DSL def initialize(router, block) @router = router @namespace = '' instance_eval(&block) end def namespace(new_namespace) @namespace << "/#{new_namespace}" yield @namespace = '' end def get(path, options) add_route("GET", path, options[:to]) end def patch(path, options) add_route("PATCH", path, options[:to]) end def post(path, options) add_route("POST", path, options[:to]) end def put(path, options) add_route("PUT", path, options[:to]) end def delete(path, options) add_route("DELETE", path, options[:to]) end private def add_route(method, path, application) path_with_namespace = add_namespace_to_path(path) @router.add_route(method, path_with_namespace, application) end def add_namespace_to_path(path) path = "#{@namespace}/#{path}" path = path.gsub('//', '/') path = path.gsub(/\/$/, '') path end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
galago-router-0.1.0 | lib/galago/router/dsl.rb |