class Tiny::Request
- Tiny::Request
- Reference
- Object
Overview
A facade which sits in front of HTTP::Request,
providing a few helper methods. The object is passed into the block of
Tiny's serve
method.
serve do |request, response|
# Handle a GET request
request.get do
# Code here is run only for GET requests...
end
# Handle a POST request
request.post do
# Code here is run only for POST requests...
end
end
Defined in:
tiny/request.crConstructors
-
.new(context : HTTP::Server::Context)
Create the request object
Instance Method Summary
-
#delete(&block)
Specify a block to handle DELETE requests
-
#get(&block)
Specify a block to handle GET requests
- #handlers : Hash(Tiny::Request::Method, -> Nil)
-
#head(&block)
Specify a block to handle HEAD requests
-
#options(&block)
Specify a block to handle OPTIONS requests
-
#params : Hash(String, Array(JSON::Type) | Bool | Float64 | Hash(String, JSON::Type) | Int64 | String | Nil)
The request parameters for this request
-
#patch(&block)
Specify a block to handle PATCH requests
-
#post(&block)
Specify a block to handle POST requests
-
#put(&block)
Specify a block to handle PUT requests
Macro Summary
-
method_missing(call)
Cascade missing methods down to the server request
Constructor Detail
Instance Method Detail
Specify a block to handle DELETE requests
request.delete do
# Code here is run only for DELETE requests...
end
Specify a block to handle GET requests
request.get do
# Code here is run only for GET requests...
end
Specify a block to handle HEAD requests
request.head do
# Code here is run only for HEAD requests...
end
Specify a block to handle OPTIONS requests
request.options do
# Code here is run only for OPTIONS requests...
end
This is specified automatically by Tiny, in order to
implement Access Control. If you override the #options
handler you will need to handle this yourself.
The request parameters for this request
Specify a block to handle PATCH requests
request.patch do
# Code here is run only for PATCH requests...
end
Specify a block to handle POST requests
request.post do
# Code here is run only for POST requests...
end
Specify a block to handle PUT requests
request.put do
# Code here is run only for PUT requests...
end