-
-
Save AD7six/d695da6bc429a1ffcd9e to your computer and use it in GitHub Desktop.
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
<?php | |
require_once __DIR__.'/../silex.phar'; | |
use \Symfony\Component\HttpFoundation\Response; | |
$app = new Silex\Application(); | |
$mounted = new Silex\Application(); | |
$mounted->get('/', function () use ($mounted) { | |
echo "{get: true}"; | |
die; | |
}); | |
$mounted->post('/', function () use ($mounted) { | |
echo "{post: true}"; | |
die; | |
}); | |
$mounted->delete('/', function () use ($mounted) { | |
echo "{delete: true}"; | |
die; | |
}); | |
$app->mount('/mounted', $mounted); | |
$app->get('/', function () use ($app) { | |
$html = <<<INDEX | |
<head> | |
</head> | |
<body> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script> | |
<script> | |
$.get('/not_mounted', function(resp) { console.log(resp); }); | |
$.ajax({ | |
type: "DELETE", | |
url: '/not_mounted', | |
data: true, | |
success: function(resp) { console.log(resp); } | |
}); | |
$.post('/not_mounted', {'foo': 'bar123'}, function(resp) { console.log(resp); }); | |
$.get('/mounted', function(resp) { console.log(resp); }); | |
$.ajax({ | |
type: "DELETE", | |
url: '/mounted', | |
data: true, | |
success: function(resp) { console.log(resp); } | |
}); | |
$.post('/mounted', {'foo': 'bar123'}, function(resp) { console.log(resp); }); | |
</script> | |
</body> | |
</html> | |
INDEX; | |
return new Response( | |
$html, | |
200, | |
array('Content-Type' => 'text/html') | |
); | |
}); | |
$app->get('/not_mounted', function () use ($app) { | |
echo "{get: true}"; | |
die; | |
}); | |
$app->post('/not_mounted', function () use ($app) { | |
echo "{post: true}"; | |
die; | |
}); | |
$app->delete('/not_mounted', function () use ($app) { | |
echo "{delete: true}"; | |
die; | |
}); | |
$app->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment