site: allow to directly mount api
This commit is contained in:
parent
cc449cd9d7
commit
84a068e5a8
3 changed files with 17 additions and 3 deletions
|
@ -6,7 +6,6 @@ app->secrets(["unused"]);
|
|||
app->static->paths(["s"]);
|
||||
app->static->prefix("/s");
|
||||
|
||||
plugin Mount => { "/api/v0" => "script/pooru-api-v0" };
|
||||
plugin Mount => { "/" => "script/pooru-site" };
|
||||
|
||||
app->start;
|
||||
|
|
|
@ -82,12 +82,21 @@ sub startup ($self)
|
|||
my $config = $self->plugin("Config");
|
||||
$self->secrets($config->{secrets});
|
||||
|
||||
my %api;
|
||||
if (defined(my $m = $config->{pooru_api}->{v0}->{mount})) {
|
||||
$api{v0} = $self->plugin("Mount" => {
|
||||
$m => $self->home->child("script", "pooru-api-v0"),
|
||||
})->to_string;
|
||||
} else {
|
||||
$api{v0} = $config->{pooru_api}->{v0}->{endpoint};
|
||||
}
|
||||
|
||||
$self->helper(storage => sub {
|
||||
state $storage = Pooru::Storage::Static->
|
||||
new($config->{store}, "/s/");
|
||||
});
|
||||
$self->helper(api_v0_url => sub {
|
||||
return Mojo::URL->new($self->config("pooru_api")->{v0});
|
||||
return Mojo::URL->new("$api{v0}/");
|
||||
});
|
||||
$self->helper(extended_pager => \&extended_pager);
|
||||
$self->helper(tag_for_pager_shortcut => \&tag_for_pager_shortcut);
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
{
|
||||
pooru_api => {
|
||||
v0 => "http://127.0.0.1:3000/api/v0/",
|
||||
v0 => {
|
||||
# Recommended for development.
|
||||
mount => "/api/v0",
|
||||
|
||||
# To run in a different location:
|
||||
#endpoint => "https://api.example.com/v0",
|
||||
},
|
||||
},
|
||||
|
||||
store => "db/pooru.storable",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue