vibe.d beta banner
get vibe.d
0.10.1

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

Function status

Sets the response status code.

void status (
  int statusCode
) @safe;

Parameters

NameDescription
statusCode the HTTPStatus code to send to the client Note that this may only be called from a function/method registered using registerWebInterface.

Example

import vibe.data.json : Json;

class WebService {
	// POST /item
	Json postItem() {
		status(HTTPStatus.created);
		return Json(["id": Json(100)]);
	}
}

void run()
{
	auto router = new URLRouter;
	router.registerWebInterface(new WebService);

	auto settings = new HTTPServerSettings;
	settings.port = 8080;
	listenHTTP(settings, router);
}
Authors

Sönke Ludwig

Copyright

© 2013-2016 Sönke Ludwig

License

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