header

Sets a response header.

@safe
void
header
(
string name
,
string value
)

Parameters

name string

name of the header to set

value string

value of the header to set

Note that this may only be called from a function/method registered using registerWebInterface.

Examples

import vibe.data.json : Json;

class WebService {
	// POST /item
	Json postItem() {
		header("X-RateLimit-Remaining", "59");
		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);
}

Meta