summaryrefslogtreecommitdiff
path: root/pinyweb/cgi-bin
diff options
context:
space:
mode:
authorjrayhawk+piny.be@omgwallhack.org <jrayhawk@dev.piny.svcs.cs.pdx.edu>2011-01-18 22:11:49 -0800
committerjrayhawk+piny.be@omgwallhack.org <jrayhawk@dev.piny.svcs.cs.pdx.edu>2011-01-18 22:11:49 -0800
commit30774537433fcf6e7818520cc3e80d36c0a63013 (patch)
tree30750d697bb10d97b2d344fad48473ada8614d41 /pinyweb/cgi-bin
parent53d9d204ac838f6f2e2c46d4c9a764dc53427e45 (diff)
parenta586352a0c9e9387987a1645842f4636c65f48be (diff)
downloadpiny-code-30774537433fcf6e7818520cc3e80d36c0a63013.tar.gz
piny-code-30774537433fcf6e7818520cc3e80d36c0a63013.zip
Merge branch 'master' of piny.be:/srv/git/piny-code
Diffstat (limited to 'pinyweb/cgi-bin')
-rwxr-xr-xpinyweb/cgi-bin/checkconstraint.cgi38
1 files changed, 22 insertions, 16 deletions
diff --git a/pinyweb/cgi-bin/checkconstraint.cgi b/pinyweb/cgi-bin/checkconstraint.cgi
index 8db0903..e0a59c3 100755
--- a/pinyweb/cgi-bin/checkconstraint.cgi
+++ b/pinyweb/cgi-bin/checkconstraint.cgi
@@ -11,29 +11,35 @@ use Piny;
my $q = CGI->new( );
-my $type = $q->param( 't' );
-my $value = $q->param( 'v' );
-
-if ( not defined $type or not defined $value ) {
- print "Status: 400 Bad Request\nContent-type: application/json\n\n";
- print encode_json( { "ok" => JSON::false, "msg" => "Unable to validate due to client-side error, please reload this page. Required parameter missing." } );
+if ( $q->request_method( ) eq "OPTIONS" ) {
+ print "Status: 200 OK\nAccess-Control-Allow-Headers: *\nAccess-Control-Allow-Methods: GET, OPTIONS, POST\nAccess-Control-Allow-Origin: *\nAccess-Control-Max-Age: 3600\nContent-Type: text/plain\n\n";
} else {
- my $constraint = find_type_constraint( $type );
-
- if ( not defined $constraint ) {
- print "Status: 400 Bad Request\nContent-type: application/json\n\n";
- print encode_json( { "ok" => JSON::false, "msg" => "Unable to validate due to client-side error, please reload this page. Invalid constraint name." } );
- } else {
+ my $type = $q->param( 't' );
+ my $value = $q->param( 'v' );
+ if ( not defined $type or not defined $value ) {
print "Status: 200 OK\nContent-type: application/json\n\n";
+ print encode_json( { "ok" => JSON::false, "msg" => "Unable to validate due to client-side error, please reload this page. Required parameter missing." } );
+ } else {
- my $error = $constraint->validate( $value );
+ my $constraint = find_type_constraint( $type );
- if ( defined $error ) {
- print encode_json( { "ok" => JSON::false, "msg" => $error } );
+ if ( not defined $constraint ) {
+ print "Status: 200 OK\nContent-type: application/json\n\n";
+ print encode_json( { "ok" => JSON::false, "msg" => "Unable to validate due to client-side error, please reload this page. Invalid constraint name." } );
} else {
- print encode_json( { "ok" => JSON::true } );
+
+ print "Status: 200 OK\nContent-type: application/json\n\n";
+
+ my $error = $constraint->validate( $value );
+
+ if ( defined $error ) {
+ print encode_json( { "ok" => JSON::false, "msg" => $error } );
+ } else {
+ print encode_json( { "ok" => JSON::true } );
+ };
+
};
};