Changeset 2624 in ProjectBuilder for devel/pb-server/lib/ProjectBuilder.pm
- Timestamp:
- Apr 17, 2020, 8:27:38 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-server/lib/ProjectBuilder.pm
r2461 r2624 1 1 package ProjectBuilder; 2 2 use Mojo::Base 'Mojolicious'; 3 use ProjectBuilder::Model::Confs; 4 use Data::Dumper; 5 use ProjectBuilder::YAML; 6 use JSON; 3 7 4 use ProjectBuilder::Model::Confs; 5 8 # This method will run once at server start 6 9 sub startup { 7 10 my $self = shift; 8 11 9 # Configuration 10 #$self->secrets([split /:/, $ENV{'BLOG_SECRETS'} || 'super:s3cret']); 11 12 print Dumper($self); 12 13 # Model 13 #$self->helper(pg => sub { state $pg = Mojo::Pg->new($ENV{'BLOG_PG_URL'}) });14 14 $self->helper(confs => sub { state $confs = ProjectBuilder::Model::Confs->new() }); 15 15 16 # Migrate to latest version if necessary 17 #my $path = $self->home->rel_file('migrations/blog.sql'); 18 #$self->pg->migrations->name('blog')->from_file($path)->migrate; 16 # Load configuration from hash returned by config file - doesn't work for now 17 #my $config = $self->plugin('Config' => { file => 'etc/pb-server.json' }); 19 18 20 # Swagger API endpoints 19 # Configure the application 20 #$self->secrets([split /:/, $ENV{'BLOG_SECRETS'} || 'super:s3cret']); 21 #$self->secrets($config->{secrets}); 22 23 # Load Open API endpoins 21 24 # /api * api 22 25 # +/confs POST "store" … … 25 28 # +/confs/(:id) DELETE "remove" 26 29 # +/confs/(:id) GET "show" 27 $self->plugin(openapi => {url => $self->home->rel_file('api.yml')}); 30 my $c = { 31 #schema => "v3", 32 default_response_codes => [400, 401, 404, 500, 501], 33 #default_response_name => 1, 34 url => 'file:///usr/share/pb/api.yaml', 35 }; 36 $self->plugin(OpenAPI => $c); 37 print "After Plugin OpenAPI\n"; 38 #$self->plugin(OpenAPI => {schema_file => $self->home->rel_file('api.yaml'), schema => "v3"}); 28 39 29 40 # Regular web pages … … 36 47 # /confs/:id PUT "update_conf" 37 48 # /confs/:id DELETE "remove_conf" 49 50 # Router 38 51 my $r = $self->routes; 52 53 # Normal route to controller 54 $r->get('/w')->to('example#welcome'); 39 55 $r->get('/' => sub { shift->redirect_to('confs') }); 40 56 $r->get('/confs')->to('conf#list'); … … 48 64 # Swagger2 module not maintained anymore 49 65 #require Swagger2::Editor; 50 #my $editor = Swagger2::Editor->new(specification_file => $self->home->rel_file('api.y ml'));66 #my $editor = Swagger2::Editor->new(specification_file => $self->home->rel_file('api.yaml')); 51 67 #$r->route('/editor')->detour(app => $editor); 52 68 }
Note:
See TracChangeset
for help on using the changeset viewer.