http-interop / http-middleware

PSR-15 interfaces for HTTP Middleware
MIT License
73 stars 7 forks source link

Method name clash #21

Closed dbu closed 8 years ago

dbu commented 8 years ago

Middleware and ServerMiddleware both use the method process. This means that a class can't implement both interfaces. While many plugins will be specific for either client or server, the PSR should not prevent plugins that make sense as both from implementing both interfaces. If the method on ServerMiddleware would be called processServer, a class could implement both interfaces.

shadowhand commented 8 years ago

That's correct, because a server middleware is a superset of a middleware. There is no situation in which a middleware would need to implement both. The rules are quite simple:

  1. If a middleware does not require ServerRequest, it implements MiddlewareInterface.
  2. If a middleware does require ServerRequest, it implements ServerMiddlewareInterface.

Having separate methods would imply that a single middleware would have different behavior in different contexts, which is a violation of SRP.

dbu commented 8 years ago

ah right, makes sense. i felt that if its a server middleware it must implement ServerMiddleware, but if it can just implement Middleware its all fine.