aboutsummaryrefslogtreecommitdiff
path: root/src/guff/handlers
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-03-13 19:10:06 -0400
committerPaul Duncan <pabs@pablotron.org>2016-03-13 19:10:06 -0400
commit3e1697e737cae24ba398f7062c27ce4ced2b8626 (patch)
tree2b7bef87a0399f8a570e8c3ff09589bd8f83ab8d /src/guff/handlers
parent13abd228f1cfb9d43ee1a14299d57ae0523e1cab (diff)
downloadold-guff-3e1697e737cae24ba398f7062c27ce4ced2b8626.tar.bz2
old-guff-3e1697e737cae24ba398f7062c27ce4ced2b8626.zip
add test auth stub
Diffstat (limited to 'src/guff/handlers')
-rw-r--r--src/guff/handlers/test-auth.cr32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/guff/handlers/test-auth.cr b/src/guff/handlers/test-auth.cr
new file mode 100644
index 0000000..5cf5769
--- /dev/null
+++ b/src/guff/handlers/test-auth.cr
@@ -0,0 +1,32 @@
+require "../handler"
+require "../views/html/test/auth"
+
+class Guff::Handlers::TestAuthHandler < Guff::Handler
+ PATH_RE = %r{^/test/auth/?$}
+ def call(context : HTTP::Server::Context)
+ if PATH_RE.match(context.request.path.not_nil!)
+ case context.request.method
+ when "GET", "HEAD"
+ draw_page(context)
+ when "POST"
+ set_auth(context)
+ else
+ raise "unknown method"
+ end
+ else
+ call_next(context)
+ end
+ end
+
+ private def draw_page(context)
+ TestAuthHTMLView.run(@models, context)
+ end
+
+ private def set_auth(context)
+ params = HTTP::Params.parse(context.request.body as String)
+
+ # TODO: extract user id and set it in session
+
+ redirect(context, "/test/blog")
+ end
+end