Closed thekid closed 5 years ago
This could be implemented within the xp-forge/web
library as follows:
use web\frontend\{Frontend, Templates};
use web\Application;
class Service extends Application {
public function routes() {
$templates= ...
return [
'/users/{user}/avatar' => function($req, $res) { ... },
'/users' => new Frontend(new Users(), $templates)
];
}
}
The benefit would be that the avatar handler can use the full extent of the web API, including partial requests. The downside however is that possibly closely related code would be torn apart.
This could be implemented within the xp-forge/web library as follows [...]
Not necessary until now, can be reopened if necessary later on.
This pull request adds the possibility to return streams from delegates.
The
Stream::of()
method will accept any of:io.File
andio.Path
instances (for which mime types and content length are calculated if omitted)io.streams.InputStream
s (which are streamed to the response as being read from)util.Bytes
(which are transmitted as-is)