Skip to content

Commit

Permalink
de-hardcode "/yancy/api", make configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Nov 15, 2018
1 parent ffcf4b3 commit 610abe3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Mojolicious/Plugin/Yancy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ sub register {
my ( $self, $app, $config ) = @_;
my $yancy_path = $config->{yancy_path} // '/yancy';
my $route = $config->{route} // $app->routes->any( $yancy_path );
my $api_path = $config->{api_path} // '/api';
$route->to( return_to => $config->{return_to} // '/' );
$config->{api_controller} //= 'Yancy::API';

Expand Down
5 changes: 5 additions & 0 deletions lib/Yancy/Help/Config.pod
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ To customize the URL under which the Yancy editor is found. If not given,
defaults to C</yancy>. Note, the various assets will still live on the
web app under C</yancy>.

=head2 C<api_path>

To customize the URL under which the Yancy API is found. This will always
be under the C<yancy_path> route. If not given, defaults to C</api>.

=head1 SEE ALSO

L<Yancy>, L<Mojolicious::Plugin::Yancy>
Expand Down
19 changes: 19 additions & 0 deletions t/api.t
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,25 @@ subtest 'different Yancy URL' => \&test_api,
} ),
'/yancy2/api';

( $backend_url, $backend, %items ) = init_backend( $collections, %data );
subtest 'different API URL' => \&test_api,
Test::Mojo->new( 'Yancy', {
backend => $backend_url,
collections => $collections,
api_path => '/api2',
} ),
'/yancy/api2';

( $backend_url, $backend, %items ) = init_backend( $collections, %data );
subtest 'different API and Yancy URLs' => \&test_api,
Test::Mojo->new( 'Yancy', {
backend => $backend_url,
collections => $collections,
yancy_path => '/yancy2',
api_path => '/api2',
} ),
'/yancy2/api2';

subtest 'schema completely from database' => sub {
my $t = Test::Mojo->new( Yancy => {
read_schema => 1,
Expand Down

0 comments on commit 610abe3

Please sign in to comment.