Varnish VCL JSONP support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urlplus; | |
import xbody; | |
sub vcl_backend_response { | |
# Insert the JSONP callback | |
if (urlplus.query_get("callback") && beresp.http.Content-Type ~ "json") { | |
xbody.regsub("^", urlplus.query_get("callback") + "("); | |
xbody.regsub("$", ");"); | |
set beresp.http.Content-Type = regsub(beresp.http.Content-Type, "json", "javascript"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment