diff options
Diffstat (limited to 'src/guff.cr')
-rw-r--r-- | src/guff.cr | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/src/guff.cr b/src/guff.cr index 7e32bfc..b19db4c 100644 --- a/src/guff.cr +++ b/src/guff.cr @@ -17,20 +17,6 @@ module Guff end end - class Handler < ::HTTP::Handler - getter :model - getter :config - - def initialize(@model : Model, @config : Config) - end - - def call(context : HTTP::Server::Context) - # do nothing by default - call_next(context) - end - end - - class BlogHandler < Handler MATCHES = [%r{ ^/ @@ -77,13 +63,8 @@ module Guff $ }x, %r{ - ^/ - # match index - blog/? - | - - $ + ^/$ }x] def call(context : HTTP::Server::Context) @@ -103,9 +84,17 @@ module Guff "baz": "test slug baz", } + RE = Regex.new("^/(?:" + MOCK_SLUGS.keys.join("|") + ").html$") + def call(context : HTTP::Server::Context) - puts "SlugHandler: path = %s" % [context.request.path] - call_next(context) + if md = RE.match(context.request.path || "") + context.response.puts "SlugHandler: path = %s, md = %s" % [ + context.request.path, + md.to_s + ] + else + call_next(context) + end end end |