| 1 | # | ||
| 2 | # This file is part of WebDyne. | ||
| 3 | # | ||
| 4 | # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>. | ||
| 5 | # | ||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||
| 8 | # | ||
| 9 | # Full license text is available at: | ||
| 10 | # | ||
| 11 | # <http://dev.perl.org/licenses/> | ||
| 12 | # | ||
| 13 | |||
| 14 | |||
| 15 | # | ||
| 16 | # | ||
| 17 | package WebDyne::PSGI::Constant; | ||
| 18 | |||
| 19 | |||
| 20 | # Pragma | ||
| 21 | # | ||
| 22 | use strict qw(vars); | ||
| 23 | use vars qw($VERSION @ISA %Constant); | ||
| 24 | use warnings; | ||
| 25 | no warnings qw(once); | ||
| 26 | |||
| 27 | |||
| 28 | # External modules | ||
| 29 | # | ||
| 30 | use File::Basename; | ||
| 31 | |||
| 32 | |||
| 33 | # Does the heavy liftying of importing into caller namespace | ||
| 34 | # | ||
| 35 | require WebDyne::Constant; | ||
| 36 | @ISA=qw(WebDyne::Constant); | ||
| 37 | |||
| 38 | |||
| 39 | # Version information | ||
| 40 | # | ||
| 41 | $VERSION='3.029'; | ||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | # Hash of constants | ||
| 46 | # <<< | ||
| 47 | %Constant=( | ||
| 48 | |||
| 49 | |||
| 50 | # Document Root, usually supplied as env var or command line option but | ||
| 51 | # can be set here. | ||
| 52 | # | ||
| 53 | DOCUMENT_ROOT => undef, | ||
| 54 | |||
| 55 | |||
| 56 | # Document default - will be served if exists in DOCUMENT_ROOT and no other | ||
| 57 | # file specified. | ||
| 58 | # | ||
| 59 | DOCUMENT_DEFAULT => 'app.psp', | ||
| 60 | |||
| 61 | |||
| 62 | # File to use for indexing | ||
| 63 | # | ||
| 64 | WEBDYNE_PSGI_INDEX => 'index.psp', | ||
| 65 | |||
| 66 | |||
| 67 | # Middleware config, static module. Enable per app with static => 1 | ||
| 68 | # or globally by setting WEBDYNE_PSGI_STATIC. | ||
| 69 | # | ||
| 70 | # Serve any static file except .psp | ||
| 71 | # | ||
| 72 | #WEBDYNE_PSGI_MIDDLEWARE_STATIC => qr{^(?!.*\.psp$).*\.\w+$}, | ||
| 73 | # | ||
| 74 | # Just common files | ||
| 75 | # | ||
| 76 | WEBDYNE_PSGI_MIDDLEWARE_STATIC => qr{\.(?:css|js|jpg|jpeg|png|gif|svg|ico|woff2?|ttf|eot|otf|webp|map|txt|inc|htm|html)$}i, | ||
| 77 | |||
| 78 | |||
| 79 | # Serve static files ? | ||
| 80 | # | ||
| 81 | WEBDYNE_PSGI_STATIC => 0, | ||
| 82 | |||
| 83 | |||
| 84 | # All other middleware. Uncomment/modify as required | ||
| 85 | # | ||
| 86 | WEBDYNE_PSGI_MIDDLEWARE => [ | ||
| 87 | |||
| 88 | #[ 'Debug' => | ||
| 89 | # { enabled => 1 } | ||
| 90 | #], | ||
| 91 | |||
| 92 | # If given as a sub code ref then option hash ref is first param | ||
| 93 | # | ||
| 94 | [ 'Static' => sub { | ||
| 95 | { path=>$WebDyne::PSGI::WEBDYNE_PSGI_MIDDLEWARE_STATIC, root=>(-f $_[0]->{'root'}) ? dirname($_[0]->{'root'}) : $_[0]->{'root'}, pass_through=>1 } | ||
| 96 | }] | ||
| 97 | |||
| 98 | |||
| 99 | ], | ||
| 100 | |||
| 101 | |||
| 102 | # Environment variables to keep, needs to be array ref | ||
| 103 | # | ||
| 104 | WEBDYNE_PSGI_ENV_KEEP => [qw(DOCUMENT_ROOT DOCUMENT_DEFAULT)], | ||
| 105 | WEBDYNE_PSGI_ENV_SET => {}, | ||
| 106 | |||
| 107 | |||
| 108 | # Warn on error ? | ||
| 109 | # | ||
| 110 | WEBDYNE_PSGI_WARN_ON_ERROR => undef, | ||
| 111 | |||
| 112 | |||
| 113 | ); | ||
| 114 | # >>> | ||
| 115 | |||
| 116 | |||
| 117 | # Done | ||
| 118 | # | ||
| 119 | 1; | ||
| 120 | __END__ |