Move RSS into its own controller
This commit is contained in:
27
app/controllers/RSSController.php
Normal file
27
app/controllers/RSSController.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class RSSController extends Controller {
|
||||
public function feedAction() {
|
||||
$feed = RSS::feed('2.0', 'UTF-8');
|
||||
$feed->channel([
|
||||
'title' => Setting::get('app_name'),
|
||||
'description' => 'Status Feed',
|
||||
'link' => Setting::get('app_domain'),
|
||||
]);
|
||||
|
||||
Incident::get()->map(function($incident) use ($feed) {
|
||||
$feed->item([
|
||||
'title' => $incident->name,
|
||||
'message' => $incident->message,
|
||||
'component' => $incident->parent->name,
|
||||
'status' => $incident->humanStatus,
|
||||
'created_at' => $incident->created_at,
|
||||
'updated_at' => $incident->updated_at
|
||||
]);
|
||||
});
|
||||
|
||||
return Response::make($feed, 200, [
|
||||
'Content-Type' => 'text/xml'
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -21,26 +21,4 @@
|
||||
Route::get('/auth/logout', 'AuthController@logoutAction');
|
||||
});
|
||||
|
||||
Route::get('/rss', function() {
|
||||
$feed = RSS::feed('2.0', 'UTF-8');
|
||||
$feed->channel([
|
||||
'title' => Setting::get('app_name'),
|
||||
'description' => 'Status Feed',
|
||||
'link' => Setting::get('app_domain'),
|
||||
]);
|
||||
|
||||
Incident::get()->map(function($incident) use ($feed) {
|
||||
$feed->item([
|
||||
'title' => $incident->name,
|
||||
'message' => $incident->message,
|
||||
'component' => $incident->parent->name,
|
||||
'status' => $incident->humanStatus,
|
||||
'created_at' => $incident->created_at,
|
||||
'updated_at' => $incident->updated_at
|
||||
]);
|
||||
});
|
||||
|
||||
return Response::make($feed, 200, [
|
||||
'Content-Type' => 'text/xml'
|
||||
]);
|
||||
});
|
||||
Route::get('/rss', 'RSSController@feedAction');
|
||||
|
||||
Reference in New Issue
Block a user