vibe.d beta banner
get vibe.d
0.7.30

Function URLRouter.route

Returns a single route handle to conveniently register multiple methods.

Prototype

URLRoute route(
  string path
);

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 RejectedSoftware e.K.

License

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