vibe.d beta banner
get vibe.d

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

Function Session.opApply

Enables foreach-iteration over all keys of the session.

int opApply (
  scope @safe int delegate(string) del
) @safe;


//import vibe.http.server;
// workaround for cyclic module ctor compiler error
class HTTPServerRequest { Session session; }
class HTTPServerResponse { import; OutputStream bodyWriter() @safe { assert(false); } string contentType; }

// sends all session entries to the requesting browser
// assumes that all entries are strings
void handleRequest(scope HTTPServerRequest req, scope HTTPServerResponse res)
	res.contentType = "text/plain";
	req.session.opApply((key) @safe {
		res.bodyWriter.write(key ~ ": " ~ req.session.get!string(key) ~ "\n");
		return 0;

package void destroy() @safe { m_store.destroy(m_id); 

Jan Krüger, Sönke Ludwig, Ilya Shipunov


© 2012-2013 Sönke Ludwig


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