Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organizes Controllers Helper Methods #357

Merged
merged 5 commits into from
Nov 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "../../../spec_helper"
require "../../../../spec_helper"

module Amber::Controller
module Amber::Controller::Helpers
describe Redirector do
describe "#redirect" do
it "redirects to location" do
Expand Down
5 changes: 2 additions & 3 deletions src/amber/controller/base.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ require "http"

require "./render"
require "./filters"
require "./redirect"
require "./helpers/*"

module Amber::Controller
class Base
include Helpers::CSRF
include Helpers::Redirect
include Render
include RedirectMethods
include Callbacks
include Helpers::Tag

protected getter context : HTTP::Server::Context
protected getter params : Amber::Validators::Params
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Amber::Controller
module RedirectMethods
module Amber::Controller::Helpers
module Redirect
def redirect_to(location : String, **args)
Redirector.new(location, **args).redirect(self)
end
Expand Down
2 changes: 1 addition & 1 deletion src/amber/controller/helpers/tags.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Amber::Controller::Helpers
module Tag
module CSRF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably name the file csrf.cr as well if you're changing the name of the module.

def csrf_token
Amber::Pipe::CSRF.token(context).to_s
end
Expand Down