aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-03-10 09:14:01 -0500
committerPaul Duncan <pabs@pablotron.org>2016-03-10 09:14:01 -0500
commitadfc9a07d407a9e29bcd7d8af4f24bf7d75c9fe6 (patch)
tree46b4c81d54f420da1474cc0e4687203761cffca9
parent4d5aa40675ce677497a725cbbe84bd3ece2a164f (diff)
downloadold-guff-adfc9a07d407a9e29bcd7d8af4f24bf7d75c9fe6.tar.bz2
old-guff-adfc9a07d407a9e29bcd7d8af4f24bf7d75c9fe6.zip
refactor redirect
-rw-r--r--src/guff/handler.cr5
-rw-r--r--src/guff/handlers/test.cr9
2 files changed, 7 insertions, 7 deletions
diff --git a/src/guff/handler.cr b/src/guff/handler.cr
index ce225eb..357ed1f 100644
--- a/src/guff/handler.cr
+++ b/src/guff/handler.cr
@@ -11,5 +11,10 @@ module Guff
# do nothing by default
call_next(context)
end
+
+ private def redirect(context, url : String)
+ context.response.status_code = 302
+ context.response.headers["location"] = url
+ end
end
end
diff --git a/src/guff/handlers/test.cr b/src/guff/handlers/test.cr
index f3ba35c..f87800e 100644
--- a/src/guff/handlers/test.cr
+++ b/src/guff/handlers/test.cr
@@ -29,7 +29,7 @@ class Guff::Handlers::TestHandler < Guff::Handler
tags: ["_blog"] + (params["tags"] || "").to_s.split(" "),
)
- redirect(context)
+ redirect(context, "/test")
end
private def set_state(context)
@@ -40,11 +40,6 @@ class Guff::Handlers::TestHandler < Guff::Handler
state: params["state"].to_s,
)
- redirect(context)
- end
-
- private def redirect(context)
- context.response.status_code = 302
- context.response.headers["location"] = "/test"
+ redirect(context, "/test")
end
end