Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Provide http-interop compatibility #75

Merged

Commits on Oct 24, 2016

  1. Configuration menu
    Copy the full SHA
    7c5c635 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    386bd9e View commit details
    Browse the repository at this point in the history

Commits on Oct 27, 2016

  1. Configuration menu
    Copy the full SHA
    1b20899 View commit details
    Browse the repository at this point in the history
  2. Added Dispatch::process to allow processing http-interop middleware

    `Next` will be called via its `process()` method when invoked by
    http-interop middleware; as such, it can invoke a separate method on
    Dispatch.
    
    This patch introduces `Dispatch::process()`, which then determines how
    to delegate the route provided. For non-http-interop middleware, it will
    raise an exception if the `Dispatch` instance does not have a response
    prototype injected, or if the request is a non-server-side request. When
    dispatching http-interop middleware, if an exception is caught, it
    raises exceptions for the same conditions, but otherwise delegates to
    the next error handler.
    weierophinney committed Oct 27, 2016
    Configuration menu
    Copy the full SHA
    ba4d0ba View commit details
    Browse the repository at this point in the history
  3. Ensure __invoke/process can each handle both types of middleware

    Extracted actual handler processing into:
    
    - dispatchCallableMiddleware()
    - dispatchInteropMiddleware()
    
    Each now tests for the handler type received and proxies to the
    appropriate method.
    weierophinney committed Oct 27, 2016
    Configuration menu
    Copy the full SHA
    6c8b317 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e0ff957 View commit details
    Browse the repository at this point in the history
  5. Have Next implement DelegateInterface

    `Next` now implements `DelegateInterface`, to allow usage with
    PSR-15/http-interop middleware.
    
    For this to work, the following changes were made:
    
    - `Next` now optionally allows setting a response prototype. If none is
      set when `__invoke()` is first called, the instance will memoize the
      response.
    - `setResponsePrototype()` also sets the response prototype on the
      composed `Dispatch` instance.
    - `process()` was added, and programmed to operate exactly as
      `__invoke()`, with the following additional behaviors/behavior
      changes:
      - it calls `Dispatch::process()` instead of `Dispatch::__invoke()`.
      - if the queue is empty:
        - if no response prototype exists, an exception is thrown
        - if the request is not a server request, an exception is thrown
        - if one exists, that value will be passed to the `$done` handler
      - if delegating to the next in the queue, it uses its own `process()`
        method, and not the `__invoke()` method.
      - if the middleware dispatched does not return a response, and no
        response prototype is present, it raises an exception.
    - internal methods typehinting on `ServerRequestInterface` were updated
      to hint on `RequestInterface` instead, as they were only operating on
      methods defined in that looser interface.
    weierophinney committed Oct 27, 2016
    Configuration menu
    Copy the full SHA
    7291c18 View commit details
    Browse the repository at this point in the history

Commits on Oct 28, 2016

  1. MiddlewarePipe as http-interop middleware

    `Next`:
    
    - Allows composing a `DelegateInterface` instance as the `$done`
      property. Invokes this differently based on whether it is callable or
      a delegate, and now only raises exceptions for missing response
      prototype or invalid request type when invoking a callable.
    
    `MiddlewarePipe`:
    
    - Now implements http-interop `ServerMiddlewareInterface`
    - Added response prototype composition; can set it, as well as test if
      one is already set.
    - Updated `pipe()` to allow piping http-interop middleware.
    - `__invoke()` now injects its `$response` argument as the `Next`
      response prototype.
    - Added `process()`:
      - Creates a `Next` instance using the `$delegate` provided.
      - Sets the `Next` response prototype if it has one composed itself.
      - Calls `Next::process()` with the provided request.
      - Returns the result if it is a response, but otherwise the composed
        response prototype.
    
    `Dispatch`:
    
    - Prior to dispatching `MiddlewarePipe` middleare, it now injects a
      `MiddlewarePipe` with its own response prototype if the pipeline does
      not yet compose one.
    weierophinney committed Oct 28, 2016
    Configuration menu
    Copy the full SHA
    9b817a2 View commit details
    Browse the repository at this point in the history

Commits on Nov 1, 2016

  1. Rename $done to $nextDelegate

    - `$done` verbiage is retained *within* the `__invoke()` and `process()`
      methods, but the property name and `dispatchDone()` methods are
      renamed.
    weierophinney committed Nov 1, 2016
    Configuration menu
    Copy the full SHA
    2ff5988 View commit details
    Browse the repository at this point in the history
  2. Backport CallableMiddlewareWrapper, and decorate callable middleware …

    …when piping when possible
    
    Backports the `CallableMiddlewareWrapper` from the dev-2.0.0 branch;
    `MiddlewarePipe::pipe()` will now decorate callable middleware *if a
    response prototype is present*; if not, it continues as normal.
    weierophinney committed Nov 1, 2016
    Configuration menu
    Copy the full SHA
    c9e0bf0 View commit details
    Browse the repository at this point in the history
  3. Do not close over Next instances

    If a Next instance is passed to CallableMiddlewareWrapper, do not close
    over it, as it is already invokable with the expected arguments.
    weierophinney committed Nov 1, 2016
    Configuration menu
    Copy the full SHA
    9c47415 View commit details
    Browse the repository at this point in the history
  4. Do not wrap error middleware

    Error middleware will be removed in 2.0.0, and will be handled specially
    anyways.
    weierophinney committed Nov 1, 2016
    Configuration menu
    Copy the full SHA
    4b9f140 View commit details
    Browse the repository at this point in the history
  5. Wrap callable middleware duck-typing as ServerMiddlewareInterface dif…

    …ferently
    
    `pipe()` now detects if callable middleware has two arguments, with the
    second type-hinting on `DelegateInterface`; if so, it wraps it in a new
    class, `CallableInteropMiddlewareWrapper`, which simply proxies to the
    callable middleware.
    weierophinney committed Nov 1, 2016
    Configuration menu
    Copy the full SHA
    184b5d6 View commit details
    Browse the repository at this point in the history
  6. Backported CallableDelegateDecorator to 1.3-dev branch

    Will not be used internally, but can be used by existing middleware in
    order to adapt it for http-interop.
    weierophinney committed Nov 1, 2016
    Configuration menu
    Copy the full SHA
    947c953 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    db08218 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    685be3d View commit details
    Browse the repository at this point in the history

Commits on Nov 2, 2016

  1. Completed migration guide for 1.3/2.0

    Added extensive section on http-interop.
    weierophinney committed Nov 2, 2016
    Configuration menu
    Copy the full SHA
    a1d27eb View commit details
    Browse the repository at this point in the history
  2. Update ErrorHandler and NotFoundHandler to implement http-interop

    Since `MiddlewarePipe` now allows piping http-interop middleware, and
    version 2.0.0 will remove the `MiddlewareInterface`, these can be
    written as http-interop middleware instead.
    weierophinney committed Nov 2, 2016
    Configuration menu
    Copy the full SHA
    3353a63 View commit details
    Browse the repository at this point in the history
  3. Provide callable implementation for both ErrorHandler and NotFoundHan…

    …dler
    
    Each now implements `__invoke()`, and has it proxy to `process()` after
    first wrapping the `$next` argument in a `CallableDelegateDecorator`.
    weierophinney committed Nov 2, 2016
    Configuration menu
    Copy the full SHA
    64aaef5 View commit details
    Browse the repository at this point in the history
  4. Update documentation for 1.3.0 features

    Primarily, to demonstrate http-interop middleware wherever possible.
    weierophinney committed Nov 2, 2016
    Configuration menu
    Copy the full SHA
    6d186ad View commit details
    Browse the repository at this point in the history
  5. Fixed typo

    weierophinney committed Nov 2, 2016
    Configuration menu
    Copy the full SHA
    aeaf5ae View commit details
    Browse the repository at this point in the history
  6. Use existing method for conditional

    Suggested by @michaelmoussa
    weierophinney committed Nov 2, 2016
    Configuration menu
    Copy the full SHA
    70386f8 View commit details
    Browse the repository at this point in the history
  7. Removed debug code.

    weierophinney committed Nov 2, 2016
    Configuration menu
    Copy the full SHA
    5cc396b View commit details
    Browse the repository at this point in the history

Commits on Nov 3, 2016

  1. Configuration menu
    Copy the full SHA
    15e7a28 View commit details
    Browse the repository at this point in the history
  2. s/inheritDocs/inheritDoc/

    weierophinney committed Nov 3, 2016
    Configuration menu
    Copy the full SHA
    3e6d574 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    97c9d51 View commit details
    Browse the repository at this point in the history
  4. Added test for CallableInteropMiddlewareWrapper, and fixed issue reve…

    …aled by test
    
    Updated `process()` to assign local `$middleware` variable to
    `$middleware` property value.
    weierophinney committed Nov 3, 2016
    Configuration menu
    Copy the full SHA
    0d44ec6 View commit details
    Browse the repository at this point in the history
  5. Remove unused imports

    weierophinney committed Nov 3, 2016
    Configuration menu
    Copy the full SHA
    858df04 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    ba9c301 View commit details
    Browse the repository at this point in the history
  7. Added tests for CallableMiddlewareWrapper

    Ensured all behaviors work as expected.
    weierophinney committed Nov 3, 2016
    Configuration menu
    Copy the full SHA
    e831a70 View commit details
    Browse the repository at this point in the history
  8. Discovered an error with array callables

    These needed to be passed to ReflectionMethod, with each element of the
    array as discrete arguments; previously, they were passed to
    ReflectionFunction, which failed as it cannot handle arbitrary
    callables.
    weierophinney committed Nov 3, 2016
    Configuration menu
    Copy the full SHA
    296810a View commit details
    Browse the repository at this point in the history
  9. Make $responsePrototype protected

    Will likely set the response prototype during instantation in
    Expressive, and then use that as the default response if none is
    provided to `run()`; as such, it cannot be private visibility.
    weierophinney committed Nov 3, 2016
    Configuration menu
    Copy the full SHA
    3f6df04 View commit details
    Browse the repository at this point in the history