Skip to content

Instantly share code, notes, and snippets.

module cmsed.test.routes.test;
import cmsed.base.routing;
import cmsed.base.restful;
import cmsed.test.models.book;
class Test : OORoute {
@RouteGroup(null, "/test.svc") {
mixin RestfulRoute!(RestfulProtection.All, Book3, Page3);
}
}
module cmsed.test.routes;
import cmsed.test.models.book;
import cmsed.base.registration.routes;
import cmsed.base.registration.onload;
public import cmsed.test.routes.test;
shared static this() {
registerRoute!Test();
void func(bool isInstall) {
import cmsed.base;
class ExampleRoute : OORoute {
@RouteFunction(RouteType.Get, "/mypath/:myarg")
void anyNameMyFunc() {
if (http_request.params.get("myarg", "") != "") {
http_reponse.writeBody(http_request.params["myarg"]);
} else {
http_response.writeBody("You failed haha!");
import cmsed.base;
class ExampleRoute : OORoute {
@RouteFunction(RouteType.Get, "/mypath", "mytemplate")
bool anyNameFunc() {
return true;
}
}
@rikkimax
rikkimax / test.d
Created February 9, 2014 06:18
Route test for restful api and javascript models.
class Test : OORoute {
@RouteGroup(null, "/.svc") {
mixin RestfulRoute!(RestfulProtection.All, Book3, Page3);
}
}
@rikkimax
rikkimax / books.js
Created February 9, 2014 06:20
Example javascript generation from data model
var Books3 = Class({
constructor: function(_id, edition) {
this._id = _id === undefined ? "" : _id;
this.edition = Number(edition === undefined ? "0" : edition);
},
save: function() {
var this_ = this;
new Ajax.Request("/.svc/Books3/" + this._id, {
method: "POST",
parameters: {
@rikkimax
rikkimax / book.d
Created February 9, 2014 06:21
Example dvorm data model with javascript generation
module cmsed.test.models.book;
import cmsed.base.routing;
import dvorm;
@dbName("Books3")
class Book3 {
@dbId
@dbName("")
Book3Id key = new Book3Id;
mixin template MixinUDACheck(T) {
mixin("bool is" ~ T.stringof ~ " (C, string f)(C c = C.init)" ~ q{{
foreach(UDA; __traits(getAttributes, mixin("c." ~ f))) {
static if (is(UDA == T)) {
return true;
}
}
return false;
}});
T mul(T)(T x, T y) {
return x * y;
}
void test(size_t function(size_t x, size_t y) mul) {
assert(mul(2, 2) == 4);
}
void main() {
test(&mul!size_t);
{
Include: test.h
Include: test2.h
Unknown: {
something
}
Condition: 1 + 1 == 2 {