From 0a4202c5255b45564ee6c0a74b0df49061a068b5 Mon Sep 17 00:00:00 2001 From: Christian Mueller Date: Thu, 20 Feb 2014 22:53:49 +0100 Subject: [PATCH] API testing tool added --- API.md | 2 + LANDING.md | 1 + resources/public/api-test.html | 121 +++++++++++++++++++++++++++++++++ src/notehub/handler.clj | 9 +-- 4 files changed, 129 insertions(+), 4 deletions(-) create mode 100644 resources/public/api-test.html diff --git a/API.md b/API.md index ddfd20c..d376d07 100644 --- a/API.md +++ b/API.md @@ -17,6 +17,8 @@ A PID is a string chosen by the publisher and cannot be longer than 16 character All API requests must be issued with one special parameter `version` denoting the expected version of the API as a string, e.g. `1.0` (see examples below). You should always put the version of this document as a `version` parameter. +Once you obtained your PSK, you can test the API [here](/api-test.html). + ## NoteHub API Access Request To register as a publisher and gain access to NoteHub API, please [send](mailto:notehub@icloud.com?subject=NoteHub API Access Request&body=Please add [a] desired PID as a 16 char stringĀ [b] your contact information, [c] short usage explanation and [d] the URL of the resource or it's website.) an email with the following information about you: the desired PID, your contact information, a short description of what you want to do and an URL of the resource where the API will be used or its website. diff --git a/LANDING.md b/LANDING.md index 4aba518..24a6a7b 100644 --- a/LANDING.md +++ b/LANDING.md @@ -16,6 +16,7 @@ Send your feedback and comments directly to [@gravitydenier](http://twitter.com/ - **API**: Integrate the publishing functionality into your editor using the official [NoteHub API](/api). ## Changelog + - Februare 2014: a simple JS-client for API testing [added](/api-test.html). - January 2014: - Mobile friendly styling added. - NoteHub API [introduced](/api). diff --git a/resources/public/api-test.html b/resources/public/api-test.html new file mode 100644 index 0000000..87bf376 --- /dev/null +++ b/resources/public/api-test.html @@ -0,0 +1,121 @@ + + + + + +NoteHub API Testing + + + + +
+ + + + + + + +
+ +
+
+ + +
+ Submit +
+
+ + +

Request

+
+    
+

Response

+
+    
+
+ + diff --git a/src/notehub/handler.clj b/src/notehub/handler.clj index a8b2a86..b4e29b6 100644 --- a/src/notehub/handler.clj +++ b/src/notehub/handler.clj @@ -89,9 +89,6 @@ :body content}) (defroutes api-routes - (GET "/" [] (layout (get-message :api-title) - (md-node :article (slurp "API.md")))) - (GET "/note" {params :params} (generate-string (api/version-manager api/get-note params))) @@ -102,7 +99,11 @@ (generate-string (api/version-manager api/update-note params)))) (defroutes app-routes - (context "/api" [] api-routes) + (GET "/api" [] (layout (get-message :api-title) + (md-node :article (slurp "API.md")))) + + (context "/api" [] + #(ring.util.response/content-type (api-routes %) "application/json")) (GET "/" [] (layout (get-message :page-title)