vibe.d beta banner
get vibe.d
0.10.0

Asynchronous I/O that doesn’t get in your way, written in D

Function URLRouter.route

Returns a single route handle to conveniently register multiple methods.

URLRoute route (
  string path
) @safe;

Example

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);

Authors

Sönke Ludwig

Copyright

© 2012-2015 Sönke Ludwig

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.