From 02feca41d2e7afc80b64513cb1d1cb385d4741b4 Mon Sep 17 00:00:00 2001 From: Pekka Helenius Date: Thu, 24 Sep 2020 14:26:30 +0300 Subject: [PATCH] Implement REST API reference help page Signed-off-by: Pekka Helenius --- .../bookstore/web/BookController.java | 16 ++++ .../src/main/resources/messages.properties | 8 ++ .../src/main/resources/templates/apiref.html | 83 +++++++++++++++++++ .../main/resources/templates/booklist.html | 20 +++++ 4 files changed, 127 insertions(+) create mode 100644 bookstore/src/main/resources/templates/apiref.html diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java b/bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java index a6a359a..6a2358e 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java @@ -47,6 +47,7 @@ public class BookController { private CategoryRepository categoryRepository; private static final String RestJSONPageView = "json"; + private static final String RestAPIRefPageView = "apiref"; private static final String landingPageView = "index"; private static final String bookListPageView = "booklist"; @@ -58,6 +59,7 @@ public class BookController { private static final long serialVersionUID = 1L; { put("restpage", RestJSONPageView); + put("apirefpage", RestAPIRefPageView); put("indexpage", landingPageView); put("listpage", bookListPageView); @@ -236,6 +238,20 @@ public class BookController { return "redirect:../" + bookListPageView; } + ////////////////////////////// + // API REFERENCE HELP PAGE + @RequestMapping( + value = RestAPIRefPageView, + method = { RequestMethod.GET } + ) + public String webFormRestApiRef( + HttpServletRequest requestData, + HttpServletResponse responseData + ) { + httpServerLogger.log(requestData, responseData); + return RestAPIRefPageView; + } + ////////////////////////////// // REDIRECTS diff --git a/bookstore/src/main/resources/messages.properties b/bookstore/src/main/resources/messages.properties index 0513569..10c11d9 100644 --- a/bookstore/src/main/resources/messages.properties +++ b/bookstore/src/main/resources/messages.properties @@ -40,17 +40,23 @@ page.title.browser.list = Bookstore page page.title.browser.add = Add book page.title.browser.edit = Update book page.title.browser.error = Error page +page.title.browser.apiref = API Reference help page page.title.webform.list = Books page.title.webform.add = Add new book page.title.webform.edit = Update existing book page.title.webform.error = Error +page.title.webform.apiref = API Reference help page page.text.list.actions = Actions page.text.list.delete = Delete page.text.list.edit = Edit page.text.list.json = Get +page.text.apiref.endpoints = REST API end points +page.text.apiref.examples = Direct search examples +page.text.apiref.add = Adding books (Unix-alike clients) + page.text.error = Error while processing your request button.book.add = Add book @@ -59,4 +65,6 @@ button.book.edit = Update book button.page.list.return = Return to book list page button.page.list.json = Get list as JSON +button.page.apiref = How to: REST API link references + page.symbols.currency = \u20AC \ No newline at end of file diff --git a/bookstore/src/main/resources/templates/apiref.html b/bookstore/src/main/resources/templates/apiref.html new file mode 100644 index 0000000..355f43e --- /dev/null +++ b/bookstore/src/main/resources/templates/apiref.html @@ -0,0 +1,83 @@ + + + + + + + + + + page.title.browser.apiref + + + + + +

+ page.title.webform.apiref +

+ + + + + + + + + + + + + +

+ page.text.apiref.endpoints +

+ placeholder +
+ placeholder +
+ + + + + + + + + + + + + +

+ page.text.apiref.examples +

+ placeholder +
+ placeholder +
+ + + + + + + + + + +

+ page.text.apiref.add +

+ +
+ +
+ +
+ + + diff --git a/bookstore/src/main/resources/templates/booklist.html b/bookstore/src/main/resources/templates/booklist.html index 9282692..1de8084 100644 --- a/bookstore/src/main/resources/templates/booklist.html +++ b/bookstore/src/main/resources/templates/booklist.html @@ -91,6 +91,26 @@ + + + + + button.page.apiref + + + + + + + + + + + +