1 /** 2 * Copyright © DiamondMVC 2018 3 * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE) 4 * Author: Jacob Jensen (bausshf) 5 */ 6 module diamond.controllers.attributes; 7 8 import diamond.core.apptype; 9 10 static if (isWeb) 11 { 12 import diamond.http.method; 13 14 /// Attribute for default http actions. 15 struct HttpDefault {} 16 17 /// Attribute for mandatory http actions. 18 struct HttpMandatory {} 19 20 /// Attribute for http actions. 21 struct HttpAction 22 { 23 /// The http method of the action. 24 HttpMethod method; 25 26 /// The name of the action. Equivalent to /route/{action} 27 string action; 28 } 29 30 /// Attribute for authentication. 31 struct HttpAuthentication 32 { 33 /// The class to use for authentcation. It must implement IControllerAuth. 34 string authenticationClass; 35 } 36 37 /// Attribute for restricting controller actions to the restricted ips. 38 struct HttpRestricted {} 39 40 /// Attribute for disabling authentication. 41 struct HttpDisableAuth { } 42 43 /// Attribute for version-control. 44 struct HttpVersion 45 { 46 /// The version name. 47 string versionName; 48 49 /// The controller to use for the version. 50 string versionControllerClass; 51 } 52 53 static if (isWebApi) 54 { 55 /// Attribute for declaring routes. 56 struct HttpRoutes 57 { 58 /// The routes. 59 string[] routes; 60 61 /** 62 * Creates a new http routes attribute. 63 * Params: 64 * route = The route. 65 */ 66 this(string route) 67 { 68 routes = [route]; 69 } 70 71 /** 72 * Creates a new http routes attribute. 73 * Params: 74 * routes = The routes. 75 */ 76 this(string[] routes) 77 { 78 this.routes = routes; 79 } 80 81 /// Dsiabling the regular struct constructor. 82 @disable this(); 83 } 84 } 85 }