added routing to the API
This commit is contained in:
@@ -16,7 +16,14 @@ To register as a publisher and gain access to NoteHub API, please [send](mailto:
|
||||
|
||||
A simple `GET` request to the following URL:
|
||||
|
||||
http://notehub.org/api/note?version=1.0¬eID=<NOTE-ID>
|
||||
http://notehub.org/api/note
|
||||
|
||||
with the following parameters:
|
||||
|
||||
Parameter | Explanation | Type
|
||||
--- | --- | ---
|
||||
`noteID` | Note-ID | **required**
|
||||
`version` | Used API version | **required**
|
||||
|
||||
will return a JSON object containing following self explaining fields: `note`, `longURL`, `shortURL`, `statistics`, `status`.
|
||||
|
||||
@@ -39,7 +46,7 @@ Example:
|
||||
|
||||
Hence, the status of the request can be evaluated by reading of the property `status.success`. The field `status.comment`might contain an error message, a warning or any other comments from the server.
|
||||
|
||||
The note ID is a string, containing the date of publishing and a few first words of the note (usually the title), e.g.: `2014 1 3 lorem-ipsum`. This ID will be generated by NoteHub automatically.
|
||||
The note ID is a string, containing the date of publishing and a few first words of the note (usually the title), e.g.: `"2014 1 3 lorem-ipsum"`. This ID will be generated by NoteHub automatically.
|
||||
|
||||
## Note Creation
|
||||
|
||||
|
||||
@@ -184,3 +184,17 @@
|
||||
(defpage "/api" args
|
||||
(let [title (get-message :api-registration)]
|
||||
(layout title [:article.markdown (slurp "API.md")])))
|
||||
|
||||
(defpage [:get "/api/note"] {:keys [version noteID]}
|
||||
(generate-string (api/get-note noteID)))
|
||||
|
||||
(defpage [:post "/api/note"] {:keys [version note pid signature password]}
|
||||
(generate-string (api/post-note note pid signature password)))
|
||||
|
||||
(defpage [:put "/api/note"] {:keys [version noteID note pid signature password]}
|
||||
(generate-string (api/update-note noteID note pid signature password)))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
(add-note (build-key date test-title) test-note "12345qwert")
|
||||
(get-note (build-key date test-title)))
|
||||
test-note))
|
||||
#_(is (valid-password? (build-key date test-title) "12345qwert"))
|
||||
(is (valid-password? (build-key date test-title) "12345qwert"))
|
||||
(is (= (do
|
||||
(update-note (build-key date test-title) "update" "12345qwert")
|
||||
(get-note (build-key date test-title)))
|
||||
|
||||
Reference in New Issue
Block a user