Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Gem Version Build Status

WebPipe

web_pipe is a modular rack application builder through a pipe of operations on an immutable struct.

In order to use in conjunction with dry-rb ecosystem, see also dry-web-web_pipe.

If you want to use it with a Rails project, don't miss docs for the rails extension.

  1. Introduction
  2. Design model
  3. Building a rack application
  4. Plugging operations
    1. Resolving operations
    2. Injecting operations
    3. Composing operations
    4. Inspecting operations
  5. Using rack middlewares
    1. Injecting middlewares
    2. Composing middlewares
    3. Inspecting middlewares
  6. Composing applications
  7. Connection struct
    1. Sharing data downstream
    2. Halting the pipe
    3. Configuring the connection struct
  8. DSL free usage
  9. Plugs
    1. Config
    2. ContentType
  10. Testing
  11. Extensions
    1. Container
    2. Cookies
    3. Flash
    4. Dry Schema
    5. Hanami View
    6. Not found
    7. Params
    8. Rails
    9. Redirect
    10. Router params
    11. Session
    12. URL
  12. Recipes
    1. dry-rb integration
    2. hanami-router integration
    3. 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. Common needs are covered and while you can expect some API changes, they won't be very important and everything will be properly documented.

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.