1 /// Defines the REST API
2 module api;
3 
4 import vibe.web.rest;
5 
6 interface ForumAPI {
7 	// base path /threads/
8 	Collection!ThreadAPI threads();
9 }
10 
11 interface ThreadAPI {
12 	// define the index parameters used to identify the collection items
13 	struct CollectionIndices {
14 		string _thread_name;
15 	}
16 
17 	// base path /threads/:thread_number/posts/
18 	Collection!PostAPI posts(string _thread_name);
19 
20 	// POST /threads/
21 	// Posts a new thread
22 	void post(string name, string message);
23 
24 	// GET /threads/
25 	// Returns a list of all thread names
26 	string[] get();
27 }
28 
29 interface PostAPI {
30 	// define the index parameters used to identify the collection items
31 	struct CollectionIndices {
32 		string _thread_name;
33 		int _post_index;
34 	}
35 
36 	// POST /threads/:thread_number/posts/
37 	// Posts a new thread reply
38 	void post(string _thread_name, string message);
39 
40 	// GET /threads/:thread_name/
41 	// Returns the number of posts in a thread
42 	int getLength(string _thread_name);
43 
44 	// GET /threads/:thread_number/posts/:post_id
45 	// Returns a specific message
46 	string getMessage(string _thread_name, int _post_index);
47 
48 	// GET /threads/:thread_number/posts/
49 	// Returns all messages of a particular thread
50 	string[] get(string _thread_name);
51 }