I want to output application/xml
as the Content-Type
for my Slim Output. Below you see my code which generates the output. All code that is commented out is unfortunately not working to output the corresponding Content-Type. Do you have any suggestions?
<?php
use PsrHttpMessageResponseInterface as Response;
use PsrHttpMessageServerRequestInterface as Request;
use SlimFactoryAppFactory;
use SlimHelperSet;
require 'vendor/autoload.php';
use Psr7MiddlewaresMiddlewareTrailingSlash;
$app = AppFactory::create();
$app->get('/{show}/feed', function(Request $request, Response $response, $args) use($app) {
$html = '<?xml version="1.0" encoding="utf-8" ?><sampletag></sampletag>';
// $app->response->headers->set('Content-Type', 'application/xml');
// $response = $response->withHeader('Content-type', 'application/xml');
$response->getBody()->write($html);
// return $response->withStatus(201)->withHeader('Content-Type', 'application/xml')->getBody()->write($html);
return $response;
});
$app->run();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…