Giter Site home page Giter Site logo

web_pipe's Introduction

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

  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. Overriding instance methods
  9. DSL free usage
  10. Plugs
    1. Config
    2. ContentType
  11. Testing
  12. 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
  13. Recipes
    1. hanami 2 & dry-rb integration
    2. Injecting dependencies through dry-auto_inject
    3. hanami-router integration
    4. 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.

web_pipe's People

Contributors

waiting-for-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

sztheory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.