0.3.0 2019-07-12
Pre-release
Pre-release
Added
- BREAKING: When plugging with
plug:, the operation is no longer specified throughwith:. Now it is just the second positional argument (9):
plug :from_container, 'container'
plug :inline, ->(conn) { conn.set_response_body('Hello world') }- It is possible to plug a block (9):
plug(:content_type) { |conn| conn.add_response_header('Content-Type', 'text/html') }- WebPipe plug's can be composed. A WebPipe proc representation is the composition of all its operations, which is an operation itself (9):
class HtmlApp
include WebPipe
plug :content_type
plug :default_status
private
def content_type(conn)
conn.add_response_header('Content-Type', 'text/html')
end
def default_status(conn)
conn.set_status(404)
end
end
class App
include WebPipe
plug :html, &HtmlApp.new
plug :body
private
def body(conn)
conn.set_response_body('Hello, world!')
end
end- WebPipe's middlewares can be composed into another WebPipe class, also through
:use:
class HtmlApp
include WebPipe
use Rack::Session::Cookie, key: 'key', secret: 'top_secret'
use Rack::MethodOverride
end
class App
include WebPipe
use HtmlApp
end