Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Middleware(features) support #29

Closed
4 tasks done
icyleaf opened this issue Aug 28, 2018 · 0 comments
Closed
4 tasks done

Middleware(features) support #29

icyleaf opened this issue Aug 28, 2018 · 0 comments

Comments

@icyleaf
Copy link
Owner

icyleaf commented Aug 28, 2018

  • middlewares(features) support with #use
    • request/response handler
    • interceptor
  • Refactoring #logger to middleware

Features

Usage:

Halite.use("logger").get "https://httpbin.org/get"
Halite.use("logger", format: "json").get "https://httpbin.org/get"
Halite.use("logger", logger: Logger.new).get "https://httpbin.org/get"

Design:

abstract class Feature
  def initialize(**options)
  end

  # Cooks with request
  def request(request : Request) : Request
    request
  end

  # Cooking with response
  def response(response : Response) : Response
    response
  end

  # Interceptor
  #
  # Intercept and cooking request and response
  def intercept(chain : Interceptor::Chain) : Interceptor::Chain
    chain
  end
end

Logger

Keep #logger in Chainable methods.

PRs

#31, #32, #36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant