Example #1
0
void t01_url(){
	INIT_LOCAL();
	
	Onion::Onion o;

	// Create an empty url handler
	Onion::Url url(o);
	
	url.add("", [](Onion::Request &req, Onion::Response &res){
		return Onion::render_to_response(_04_templates_html, std::map<std::string,std::string>{{"test","ok"}} , res);
	});
	
	o.listen();
	
	END_LOCAL();
}
Example #2
0
void t01_basic(){
  INIT_LOCAL()
  
  Onion::Onion o;
  MyHandler m;

  Onion::Url url(o);
  
  url.add("", handler);
  url.add("static", "Estatico");
  url.add<MyHandler>("m", &m, &MyHandler::index);
  
  o.setInternalErrorHandler( new Onion::HandlerMethod<MyHandler>(&m, &MyHandler::error) );
  
  o.listen();
  
  END_LOCAL()
}