Skip to content

Instantly share code, notes, and snippets.

@digitalextremist
Last active December 15, 2015 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitalextremist/5292312 to your computer and use it in GitHub Desktop.
Save digitalextremist/5292312 to your computer and use it in GitHub Desktop.
Rack routing. Updated to show wildcarding.
map "/.conference" do; run Mu::Conference end
map "/.documentation" do; run Mu::Documentation end
map "/.development" do; run Mu::Development end
map "/.sources" do; run Mu::Sourcing end
class Mu
class Development < Ma #de pulls in Sinatra::Base and performs global configurations that apply to all requests.
register Sinatra::MultiRoute
before do; Mu.protected! end
get '/', '/news' do
...
end
get '/repositories', '/code' do
...
end
get "/*" do
#de ... not found, return error 404
404
end
end
end
@seancribbs
Copy link

Following up on our Twitter conversation because 140 chars isn't enough, I'll try to translate what I see:

require 'webmachine'

module Mu
  module Development
    class NewsResource < Webmachine::Resource
      # ...
    end

    class CodeResource < Webmachine::Resource
      # ...
    end
  end

  Application = Webmachine::Application.new do |app|
    app.routes do
      add ['.development'], Development::NewsResource
      add ['.development', 'news'], Development::NewsResource
      add ['.development', 'repositories'], Development::CodeResource
      add ['.development', 'code'], Development::CodeResource
    end
  end
end

# If this is config.ru...
run Mu::Application

@digitalextremist
Copy link
Author

I didn't catch you comment here until now @seancribbs. Thanks for following up on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment