allow swagger_path installed routes to be relocated

This commit is contained in:
Oliver Gorwits
2020-04-19 18:00:15 +01:00
parent da33478504
commit b9c002477b
6 changed files with 23 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ use Dancer ':script';
use Path::Class 'dir';
use Net::Domain 'hostdomain';
use File::ShareDir 'dist_dir';
use URI::Based;
BEGIN {
if (setting('include_paths') and ref [] eq ref setting('include_paths')) {
@@ -224,4 +225,11 @@ config->{'reports'} = [ @{setting('system_reports')}, @{setting('reports')} ];
#config->{plugins}->{Swagger}->{ui_dir} =
#dir(dist_dir('App-Netdisco'), 'share', 'public', 'swagger-ui')->absolute;
# setup helpers for when request->uri_for() isn't available
# (for example when inside swagger_path())
config->{url_base}
= URI::Based->new((config->{path} eq '/') ? '' : config->{path});
config->{api_base}
= config->{url_base}->with('/api/v1')->path;
true;