File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 * JSONP Middleware Class for the Slim Framework
44 *
55 * Simple class to wrap the response of the application in an JSONP callback function.
6- * The class is triggered when a get parameter of callback is found
6+ * The class is triggered when a get parameter of callback is found
77 *
88 * @author Tom van Oorschot <tomvanoorschot@gmail.com>
99 * @since 17-12-2012
1010 */
11+
1112class JSONPMiddleware extends \Slim \Middleware
1213{
1314 public function call ()
1415 {
15- $ callback = $ this ->app ->request ()->get ('callback ' );
16+ $ callback = $ this ->app ->request ()->get ('callback ' );
1617
17- //Fetch the body first
18- $ this ->next ->call ();
18+ //Fetch the body first
19+ $ this ->next ->call ();
1920
20- //If the JSONP callback parameter is set then wrap the response body in the original
21- //callback string.
22- if (!empty ($ callback )){
23- //The response becomes a javascript response
24- $ this ->app ->contentType ('application/javascript ' );
21+ //If the JSONP callback parameter is set then wrap the response body in the original
22+ //callback string.
23+ if (!empty ($ callback )){
24+ //The response becomes a javascript response
25+ $ this ->app ->contentType ('application/javascript ' );
2526
26- $ jsonp_response = htmlspecialchars ($ callback ) . "( " .$ this ->app ->response ()->body () . ") " ;
27- $ this ->app ->response ()->body ($ jsonp_response );
28- }
29- }
27+ $ jsonp_response = htmlspecialchars ($ callback ) . "( " .$ this ->app ->response ()->body () . ") " ;
28+ $ this ->app ->response ()->body ($ jsonp_response );
29+ }
30+ }
3031}
You can’t perform that action at this time.
0 commit comments