Use proper base url by default instead of hardcoded app_dev controller

This commit is contained in:
Jordi Boggiano 2013-03-01 21:24:54 +01:00
parent b50f3ca185
commit abac2a03df
3 changed files with 6 additions and 2 deletions

View File

@ -38,7 +38,7 @@ class Configuration implements ConfigurationInterface
->addDefaultsIfNotSet() ->addDefaultsIfNotSet()
->children() ->children()
->scalarNode('enabled')->defaultTrue()->end() ->scalarNode('enabled')->defaultTrue()->end()
->scalarNode('endpoint')->defaultValue('/app_dev.php')->end() ->scalarNode('endpoint')->defaultNull()->end()
->arrayNode('request_format') ->arrayNode('request_format')
->addDefaultsIfNotSet() ->addDefaultsIfNotSet()
->children() ->children()

View File

@ -13,5 +13,5 @@
<argument type="service" id="nelmio_api_doc.doc_comment_extractor" /> <argument type="service" id="nelmio_api_doc.doc_comment_extractor" />
<tag name="nelmio_api_doc.extractor.parser" /> <tag name="nelmio_api_doc.extractor.parser" />
</service> </service>
</services> </services>
</container> </container>

View File

@ -195,6 +195,10 @@
url += api_key_parameter + '=' + $('#api_key').val(); url += api_key_parameter + '=' + $('#api_key').val();
} }
{% if endpoint == '' and app.request is defined and app.request.host -%}
{% set endpoint = app.request.getBaseUrl() -%}
{% endif -%}
// and trigger the API call // and trigger the API call
$.ajax({ $.ajax({
url: '{{ endpoint }}' + url, url: '{{ endpoint }}' + url,