From 471abda822cc9d1b08fd09b7e756a862774a9e31 Mon Sep 17 00:00:00 2001 From: PJ Dietz Date: Mon, 24 Dec 2012 08:42:44 -0500 Subject: [PATCH] Refactor ArticleControler to ArticleController Fix some typos --- ...ler.inc.php => ArticlesController.inc.php} | 2 +- samples/apisample/README.txt | 45 +++++++++++++++---- .../handlers/ArticleCollectionHandler.inc.php | 6 +-- .../handlers/ArticleItemHandler.inc.php | 8 ++-- samples/client-side-request.php | 2 +- 5 files changed, 46 insertions(+), 17 deletions(-) rename samples/apisample/{ArticlesControler.inc.php => ArticlesController.inc.php} (98%) diff --git a/samples/apisample/ArticlesControler.inc.php b/samples/apisample/ArticlesController.inc.php similarity index 98% rename from samples/apisample/ArticlesControler.inc.php rename to samples/apisample/ArticlesController.inc.php index 7ec51cc..c6ccdcc 100644 --- a/samples/apisample/ArticlesControler.inc.php +++ b/samples/apisample/ArticlesController.inc.php @@ -5,7 +5,7 @@ namespace apisample; /** * Simple class for reading and writing articles to a text file. */ -class ArticlesControler { +class ArticlesController { public $data; protected $path; diff --git a/samples/apisample/README.txt b/samples/apisample/README.txt index 0e5d6f4..6d471b8 100644 --- a/samples/apisample/README.txt +++ b/samples/apisample/README.txt @@ -1,13 +1,41 @@ -The apisample directory contains a mini API project that demonstrates all of the +The apisample directory contains a mini API project that demonstrates the main features of Well RESTEd. +Resources +--------- + +For this sample project, the only resources +are "articles", which are kind of like little mini blog posts or news feed +items. Each article contains the following fields: + + articleId: Numeric unique identifier for the article + slug: A human readable unique identifier for the article + title: Text title describing the article + excerpt: A short portion of the article's content + +In JSON, an article resource looks like this: + + { + "articleId": 1, + "slug": "good-movie", + "title": "Reports Of Movie Being Good Reach Area Man", + "excerpt": "Local resident Daniel Paxson has reportedly heard dozens of accounts from numerous friendly sources in the past two weeks confirming that the new James Bond film is pretty good. According to persons with knowledge of the situation, an unnamed friend of Paxson’s coworker Wendy Mathers watched the movie on opening weekend and found it to be “decent enough.”" + } + + +URIs +---- + +The API exposes both the collection of articles and each article individually. + /articles/ - Represents a list of articles. + Represents the collection of articles. GET - Displays a list of articles + Display the full list of articles. POST - Add a new article + Add a new article. Provide the new article in JSON format as the + request body. PUT Not allowed DELETE @@ -16,13 +44,14 @@ main features of Well RESTEd. /articles/{id} /articles/{slug} Represents one specific article identified by the numberic ID {id} or by the - alpha-numeric slug. + alpha-numeric slug {slug}. GET - Displays one specific article + Display one specific article. POST Not allowed PUT - Replace the article with the given contents + Replace the article with the new article. Provide the new article in + JSON format as the request body. DELETE - Remove the article + Remove the article. diff --git a/samples/apisample/handlers/ArticleCollectionHandler.inc.php b/samples/apisample/handlers/ArticleCollectionHandler.inc.php index 3f7d899..f9e2262 100644 --- a/samples/apisample/handlers/ArticleCollectionHandler.inc.php +++ b/samples/apisample/handlers/ArticleCollectionHandler.inc.php @@ -3,7 +3,7 @@ namespace apisample\handlers; require_once(dirname(__FILE__) . '/../../../Handler.inc.php'); -require_once(dirname(__FILE__) . '/../ArticlesControler.inc.php'); +require_once(dirname(__FILE__) . '/../ArticlesController.inc.php'); /** * Handler class for a list of articles. @@ -16,7 +16,7 @@ class ArticleCollectionHandler extends \wellrested\Handler { protected function get() { // Display the list of articles. - $articles = new \apisample\ArticlesControler(); + $articles = new \apisample\ArticlesController(); if (isset($articles->data)) { @@ -73,7 +73,7 @@ class ArticleCollectionHandler extends \wellrested\Handler { } // Ensure slug is not a duplicate. - $articles = new \apisample\ArticlesControler(); + $articles = new \apisample\ArticlesController(); if ($articles->getArticleBySlug($article['slug']) !== false) { $this->response->statusCode = 409; $this->response->setHeader('Content-type', 'text/plain'); diff --git a/samples/apisample/handlers/ArticleItemHandler.inc.php b/samples/apisample/handlers/ArticleItemHandler.inc.php index 23534f3..20be1f3 100644 --- a/samples/apisample/handlers/ArticleItemHandler.inc.php +++ b/samples/apisample/handlers/ArticleItemHandler.inc.php @@ -3,7 +3,7 @@ namespace apisample\handlers; require_once(dirname(__FILE__) . '/../../../Handler.inc.php'); -require_once(dirname(__FILE__) . '/../ArticlesControler.inc.php'); +require_once(dirname(__FILE__) . '/../ArticlesController.inc.php'); /** * Handler class for one specific article. @@ -19,7 +19,7 @@ class ArticleItemHandler extends \wellrested\Handler { protected function get() { // Read the list of articles. - $articles = new \apisample\ArticlesControler(); + $articles = new \apisample\ArticlesController(); $article = false; @@ -89,7 +89,7 @@ class ArticleItemHandler extends \wellrested\Handler { } // Read the list of articles. - $articles = new \apisample\ArticlesControler(); + $articles = new \apisample\ArticlesController(); $oldArticle = false; @@ -159,7 +159,7 @@ class ArticleItemHandler extends \wellrested\Handler { protected function delete() { // Read the list of articles. - $articles = new \apisample\ArticlesControler(); + $articles = new \apisample\ArticlesController(); $article = false; diff --git a/samples/client-side-request.php b/samples/client-side-request.php index 87a24dd..e2970cd 100644 --- a/samples/client-side-request.php +++ b/samples/client-side-request.php @@ -13,7 +13,7 @@ $rqst->uri = 'https://www.google.com/search?q=my+search+terms'; // You could also set the members individually, like this: //$rqst->protocol = 'https'; -//$rqst->hostname = ['www.google.com'; +//$rqst->hostname = 'www.google.com'; //$rqst->path = '/search'; //$rqst->query = array('q' => 'my search terms');