URLRouter.route

Returns a single route handle to conveniently register multiple methods.

class URLRouter
@safe
route
(
string path
)

Examples

void getFoo(scope HTTPServerRequest req, scope HTTPServerResponse res) { /* ... */ }
void postFoo(scope HTTPServerRequest req, scope HTTPServerResponse res) { /* ... */ }
void deleteFoo(scope HTTPServerRequest req, scope HTTPServerResponse res) { /* ... */ }

auto r = new URLRouter;

// using 'with' statement
with (r.route("/foo")) {
	get(&getFoo);
	post(&postFoo);
	delete_(&deleteFoo);
}

// using method chaining
r.route("/foo")
	.get(&getFoo)
	.post(&postFoo)
	.delete_(&deleteFoo);

// without using route()
r.get("/foo", &getFoo);
r.post("/foo", &postFoo);
r.delete_("/foo", &deleteFoo);

Meta