diff --git a/config.ru b/config.ru
index fab56e2..b1bb75d 100644
--- a/config.ru
+++ b/config.ru
@@ -1,12 +1,25 @@
-# frozen_string_literal: true
+require_relative 'lib/hyde'
-require 'rack'
-app = Rack::Builder.new do |builder|
- builder.use Rack::Lint
- builder.run (proc do |env|
- pp env
- [200, {"content-type" => "text/html"}, ["p","i","s","s"]]
- end)
+app = Hyde::Server.new do
+ path /^test\/\w+/ do
+ probe "probe"
+ end
+
+ path "/subdir/test" do
+ probe "probe"
+ end
+
+ path "/match/*/test/:test/" do
+ probe "probe"
+ end
+
+ path "/match/:test/" do
+ probe "probe"
+ end
+
+ path "/match2/*/" do
+ probe "probe"
+ end
end
run app
diff --git a/hyde.old.rb b/hyde.old.rb
deleted file mode 100644
index 78421fb..0000000
--- a/hyde.old.rb
+++ /dev/null
@@ -1,423 +0,0 @@
-# frozen_string_literal: true
-
-require 'mime-types'
-require 'webrick'
-require 'uri'
-require 'pp'
-
-# Primary module
-module Hyde
- # Hyde version
- # @type [String]
- VERSION = '0.5 (alpha)'
- attr_reader :VERSION
-
- # Hyde branding and version (for error templates)
- # @type [String]
- VLINE = "Hyde/#{Hyde::VERSION} on WEBrick/#{WEBrick::VERSION} (Ruby/#{RUBY_VERSION}/#{RUBY_RELEASE_DATE})\n"
- attr_reader :VLINE
-
- # Generate HTML error template
- # @param errortext [String] Error explanation
- # @param backtrace [String] Ruby backtrace
- def error_template(errortext, backtrace)
- <<~HTMLEOF
-
-
-
- #{WEBrick::HTMLUtils.escape(errortext)}
-
-
-
-
-
-
#{WEBrick::HTMLUtils.escape(errortext)}
-
- #{WEBrick::HTMLUtils.escape(backtrace) or "\n\n\n"}
-
-
-
#{WEBrick::HTMLUtils.escape(Hyde::VLINE)}
-
-
-
- HTMLEOF
- end
- module_function :error_template
-
- WEBrick::HTTPResponse.class_exec do
- public
-
- attr_accessor :recent_backtrace
-
- def create_error_page
- @body = Hyde.error_template(@reason_phrase, @recent_backtrace)
- end
- end
-
- # Interchangeable glob/regex/string pattern matching
- module PatternMatching
- def _prep_path(path, safe_regexp: true)
- @safe_regexp = safe_regexp
- @path = _normalize(path) if path.is_a? String
- @path = path if path.is_a? Regexp
- end
-
- # @return [Boolean]
- def _match?(path, _ctx)
- # behvaiour used by "index" method
- return true if @path == ''
- split_path = path.split('/').filter { |x| x != '' }
- if @path.is_a? Regexp
- # this chunk of fuck is needed to force regexp into 3 rules:
- # 1) unsafe regexp means match the whole (remaining) line.
- # 3) safe regexp means match only the part before the next slash
- # 2) a ._match? only returns when there are no leftovers
- # this forces the matching to work somewhat consistently
- test = @path.match _normalize_input(path) unless @safe_regexp
- test = @path.match split_path[0] if @safe_regexp
- if test and (test.pre_match == '') and (test.post_match == '')
- true
- else
- false
- end
- else
- # algorithm to match path segments until no more left in @path
- @path.split('/').filter { |x| x != '' }
- .each_with_index do |x, i|
- return false if x != split_path[i]
- end
- true
- end
- end
-
- def _normalize_input(path)
- # remove duplicate slashes and trim edge slashes
- (path.split '/').filter { |x| x != '' }.join('/')
- end
-
- def _normalize(path)
- # remove duplicate slashe s and trim edge slashes
- path = _normalize_input(path)
- # globbing behaviour simulated with regexp
- if path.match /(?#{url}.