added some basic structures
This commit is contained in:
parent
c2c053a73b
commit
bc34186b23
|
@ -0,0 +1,13 @@
|
|||
module Zero
|
||||
|
||||
# abstract class to make creation of controllers easier
|
||||
#
|
||||
# This abstract class creates an interface to make it easier to write
|
||||
# rack compatible controllers. It catches #call and creates a new instance
|
||||
# with the environment and calls #render on it.
|
||||
class Controller
|
||||
def self << call(env)
|
||||
new(Request.new(env)).render
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
module Zero
|
||||
# encapsulate the rack environment
|
||||
class Request
|
||||
attr_reader :env
|
||||
|
||||
# create a new
|
||||
def initialize(env)
|
||||
@env = env
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,22 @@
|
|||
module Zero
|
||||
# an easier interface for the response
|
||||
#
|
||||
# The response for rack has to be an array of three elements. This class makes
|
||||
# it easier to fill all the needed data.
|
||||
class Response
|
||||
attr_reader :code, :header, :body
|
||||
|
||||
# init a new response
|
||||
def initialize
|
||||
@code = 404
|
||||
@header = {}
|
||||
@body = nil
|
||||
end
|
||||
|
||||
# builds the response for rack and checks for protocol errors
|
||||
# @return Array the rack response
|
||||
def response
|
||||
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue