const std = @import("std"); const zzz = @import("zzz"); /// CRUD dispatchers definitions for a given model dispatcher definition. pub fn Crud(ModelDispatcherDefinition: type) type { return struct { /// Make a definition structure to define all CRUD operations with the provided policy. pub fn All(policy: ModelDispatcherDefinition.Policy) type { return struct { pub usingnamespace Create(policy); pub usingnamespace Read(policy); pub usingnamespace Update(policy); pub usingnamespace Delete(policy); }; } /// Make a definition structure to define model creation operation with the provided policy. pub fn Create(policy: ModelDispatcherDefinition.Policy) type { return struct { pub const create = (ModelDispatcherDefinition{ .policy = policy, .run = struct { fn f(context: ModelDispatcherDefinition.Context) void { _ = context; //TODO! } }.f, .httpMethod = zzz.HTTP.Method.POST, }).builder(); }; } /// Make a definition structure to define model retrieval operation with the provided policy. pub fn Read(policy: ModelDispatcherDefinition.Policy) type { return struct { pub const read = (ModelDispatcherDefinition{ .policy = policy, .run = struct { fn f(context: ModelDispatcherDefinition.Context) void { _ = context; //TODO! } }.f, .httpMethod = zzz.HTTP.Method.GET, }).builder(); }; } /// Make a definition structure to define model update operation with the provided policy. pub fn Update(policy: ModelDispatcherDefinition.Policy) type { return struct { pub const update = (ModelDispatcherDefinition{ .policy = policy, .run = struct { fn f(context: ModelDispatcherDefinition.Context) void { _ = context; //TODO! } }.f, .httpMethod = zzz.HTTP.Method.PATCH, }).builder(); }; } /// Make a definition structure to define model deletion operation with the provided policy. pub fn Delete(policy: ModelDispatcherDefinition.Policy) type { return struct { pub const delete = (ModelDispatcherDefinition{ .policy = policy, .run = struct { fn f(context: ModelDispatcherDefinition.Context) void { _ = context; //TODO! } }.f, .httpMethod = zzz.HTTP.Method.DELETE, }).builder(); }; } }; }