🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

web_pipe

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web_pipe

0.16.0
Rubygems
Version published
Maintainers
1
Created
Source

Gem Version Build Status

WebPipe

web_pipe is a builder of composable rack applications through a pipe of functions on an immutable struct.

web_pipe plays incredibly well with hanami 2. If you want to create a hanami 2 app with web_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.

# 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.

FAQs

Package last updated on 07 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts