|
| 1 | +#!/usr/bin/env rackup |
| 2 | +# frozen_string_literal: true |
| 3 | + |
| 4 | +require_relative "config/environment" |
| 5 | + |
| 6 | +self.freeze_app |
| 7 | + |
| 8 | +if UTOPIA.production? |
| 9 | + # Handle exceptions in production with a error page and send an email notification: |
| 10 | + use Utopia::Exceptions::Handler |
| 11 | + use Utopia::Exceptions::Mailer |
| 12 | +else |
| 13 | + # We want to propate exceptions up when running tests: |
| 14 | + use Rack::ShowExceptions unless UTOPIA.testing? |
| 15 | +end |
| 16 | + |
| 17 | +# Serve static files from "public" directory: |
| 18 | +use Utopia::Static, root: "public" |
| 19 | + |
| 20 | +use Utopia::Redirection::Rewrite, { |
| 21 | + "/" => "/welcome/index" |
| 22 | +} |
| 23 | + |
| 24 | +use Utopia::Redirection::DirectoryIndex |
| 25 | + |
| 26 | +use Utopia::Redirection::Errors, { |
| 27 | + 404 => "/errors/file-not-found" |
| 28 | +} |
| 29 | + |
| 30 | +require "utopia/localization" |
| 31 | +use Utopia::Localization, |
| 32 | + default_locale: "en", |
| 33 | + locales: ["en", "de", "ja", "zh"] |
| 34 | + |
| 35 | +require "utopia/session" |
| 36 | +use Utopia::Session, |
| 37 | + expires_after: 3600 * 24, |
| 38 | + secret: UTOPIA.secret_for(:session), |
| 39 | + secure: true |
| 40 | + |
| 41 | +use Utopia::Controller |
| 42 | + |
| 43 | +# Serve static files from "pages" directory: |
| 44 | +use Utopia::Static |
| 45 | + |
| 46 | +# Serve dynamic content: |
| 47 | +use Utopia::Content |
| 48 | + |
| 49 | +run lambda {|env| [404, {}, []]} |
0 commit comments