middleware v0.1.0
Middleware
Middleware is a library which provides a generalized implementation of the chain of responsibility pattern for Crystal.
This is heavily based on HTTP stdlib and inspiration from https://github.com/Ibsciss/ruby-middleware
Installation
Add this to your application's shard.yml
:
dependencies:
middleware:
github: russ/middleware
Usage
require "middleware"
class PushHandler
include Middleware::Handler(String)
def initialize(@to_add : String)
end
def call(env : EnvType) : String
env["result"] << @to_add
call_next(env)
end
end
context = { "result" => [] of String }
instance = Middleware::Builder.new([
PushHandler.new("foobar"),
PushHandler.new("barfoo")
] of Middleware::Handler(String))
instance.call(context)
{ "result" => ["foobar", "barfoo"] }
Contributing
- Fork it ( https://github.com/russ/Middleware/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- russ Russ Smith - creator, maintainer
Repository
middleware
Owner
Statistic
- 0
- 1
- 0
- 0
- 0
- over 2 years ago
- May 11, 2018
License
MIT License
Links
Synced at
Sun, 17 Nov 2024 07:14:59 GMT
Languages