1 module rest.iapiv1; 2 3 import vibe.d; 4 5 /++ 6 Interface definition for JSON REST API. 7 +/ 8 interface IApiV1 9 { 10 /+ 11 POST /api/v1/run 12 { 13 source: "..." 14 } 15 16 Returns: output of compiled D program with success 17 flag and parsed errors and warnings (if any 18 and success is false). 19 { 20 output: "Program Output", 21 success: true/false 22 } 23 +/ 24 struct RunOutput 25 { 26 string output; 27 bool success; 28 struct Message { 29 int line; 30 string message; 31 } 32 Message[] errors; 33 Message[] warnings; 34 } 35 @method(HTTPMethod.POST) 36 @path("/api/v1/run") 37 RunOutput run(string source); 38 39 /+ 40 GET /api/v1/source/CHAPTER/SECTION 41 42 Returns: source code (or empty if none) for the given 43 chapter and section. Also returns changed source code 44 if user switched between sections. 45 { 46 sourceCode: "..." 47 } 48 +/ 49 struct SourceOutput 50 { 51 string sourceCode; 52 } 53 @method(HTTPMethod.GET) 54 @path("/api/v1/source/:language/:chapter/:section") 55 SourceOutput getSource(string _language, string _chapter, string _section); 56 }