WebPipe
web_pipe
is a builder of composable rack applications through a pipe of
functions on an immutable struct.
web_pipe
plays incredibly well withhanami 2
. If you want to create ahanami 2
app withweb_pipe
, you can take inspiration from this sample todo application:https://github.com/waiting-for-dev/hanami_2_web_pipe_todo_app
To use in conjunction with hanami dry-rb ecosystem,
see also
dry-web-web_pipe
.
- Introduction
- Design model
- Building a rack application
- Plugging operations
- Using rack middlewares
- Composing applications
- Connection struct
- DSL free usage
- Plugs
- Testing
- Extensions
- Recipes
# config.ru
require 'web_pipe'
WebPipe.load_extensions(:params)
class HelloApp
include WebPipe
AUTHORIZED_USERS = %w[Alice Joe]
plug :html
plug :authorize
plug :greet
private
def html(conn)
conn.add_response_header('Content-Type', 'text/html')
end
def (conn)
user = conn.params['user']
if AUTHORIZED_USERS.include?(user)
conn.add(:user, user)
else
conn.
set_status(401).
set_response_body('<h1>Not authorized</h1>').
halt
end
end
def greet(conn)
conn.set_response_body("<h1>Hello #{conn.fetch(:user)}</h1>")
end
end
run HelloApp.new
Current status
web_pipe
is in active development but ready to be used in any environment.
Everyday needs are covered, and while you can expect some API changes,
they won't be essential, and we'll document everything appropriately.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/waiting-for-dev/web_pipe.
Release Policy
web_pipe
follows the principles of semantic versioning.