jorishermans/dart-forcemvc — pull request #11 by kiuz (2014-06-14 11:26:03+00:00)
Title: Added CORS to Making Cross-Domain Requests

inspired By: https://github.com/chrisbu/dartlang_json_webservice_article_code/blob/master/simpleserver/simpleserver.dart

now you can enable or disable CORS with "cors" bool parameter
WebServer server = new WebServer(... ... "other parameter" cors:true );

where are used:

void _send_response(HttpResponse response, ContentType contentType, String result) {
- response
+	if(this.Cors==true){
+	response
+ ..headers.add("Access-Control-Allow-Origin", "*, ")
+ ..headers.add("Access-Control-Allow-Methods", "POST, GET, OPTIONS")
+ ..headers.add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
+ }
... ... ...