Skip to content

Instantly share code, notes, and snippets.

@elorest
Created May 7, 2017 06:39
Show Gist options
  • Save elorest/dd6dbf800f692b1052dedc4f497bf7c1 to your computer and use it in GitHub Desktop.
Save elorest/dd6dbf800f692b1052dedc4f497bf7c1 to your computer and use it in GitHub Desktop.
require "http"
require "./*"
module Amber::Controller
class Base
include Render
include Redirect
include Callbacks
protected getter request = HTTP::Request.new("GET", "/")
protected getter response = HTTP::Server::Response.new(IO::Memory.new)
protected getter raw_params = HTTP::Params.parse("")
protected getter context : HTTP::Server::Context?
protected getter params : Amber::Validators::Params = Amber::Validators::Params.new(HTTP::Params.parse("t=t"))
def initialize(@context : HTTP::Server::Context)
set_context(@context.not_nil!)
end
def initialize
end
def set_context(@context : HTTP::Server::Context)
@request = context.request
@response = context.response
@raw_params = context.params
@params = Amber::Validators::Params.new(@raw_params)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment