BooksController { private $bookData = […]; public function indexAction() { return new JsonResponse(array_values($this->bookData)); } public function getAction($isbn) { if (!array_key_exists($isbn, $this->bookData)) { return new JsonResponse(null, 404); } return new JsonResponse($this->bookData[$isbn]); } }
class BooksController { … public function getAction($isbn) { if (!array_key_exists($isbn, $this->bookData)) { return new JsonResponse(null, 404); } return new JsonResponse($this->bookData[$isbn]); } }
/* GET home page. */ router.get('/', function (req, res, next) { res.render('index'); }); /* GET home page. */ router.get('/partials/details.html', function (req, res, next) { res.render('partials/details'); }); /* GET home page. */ router.get('/partials/list.html', function (req, res, next) { res.render('partials/list'); }); module.exports = router;
next) { res.render('index'); }); … //- book-info-website/views/index.jade doctype html html(lang="en" ng-app="booksApp") head title Book Info Website link(rel='stylesheet', href='/stylesheets/style.css') script(src='/assets/modules/angular/angular.js') script(src='/assets/modules/angular-resource/angular-resource.js') script(src='/assets/modules/angular-route/angular-route.js') script(src='/javascripts/angular/app.js') script(src='/javascripts/angular/services.js') script(src='/javascripts/angular/controllers.js') body div(ng-view)