web_pipe
web_pipe copied to clipboard
One-way pipe, composable, rack application builder
WebPipe
web_pipe is a builder of composable rack applications through a pipe of
functions on an immutable struct.
web_pipeplays incredibly well withhanami 2. If you want to create ahanami 2app withweb_pipe, you can take inspiration from this sample todo application:https://github.com/waiting-for-dev/hanami_2_web_pipe_todo_app
- Introduction
- Design model
- Building a rack application
- Plugging operations
- Resolving operations
- Injecting operations
- Composing operations
- Inspecting operations
- Using rack middlewares
- Injecting middlewares
- Composing middlewares
- Inspecting middlewares
- Composing applications
- Connection struct
- Sharing data downstream
- Halting the pipe
- Configuring the connection struct
- Overriding instance methods
- DSL free usage
- Plugs
- Config
- ContentType
- Testing
- Extensions
- Container
- Cookies
- Flash
- Dry Schema
- Hanami View
- Not found
- Params
- Rails
- Redirect
- Router params
- Session
- URL
- Recipes
- hanami 2 & dry-rb integration
- hanami-router integration
- Using all RESTful methods
# 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 authorize(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.