Sha256: 9f08dc4674be84c5b8ce548e3a2324192509dc2bfbe58c90f62ca56c4e99168e

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

require "dry/web/roda/application"
require_relative "container"

module <%= config[:camel_cased_umbrella_name] %>
  module <%= config[:camel_cased_app_name] %>
    class Web < Dry::Web::Roda::Application
      configure do |config|
        config.container = Container
        config.routes = "web/routes".freeze
      end

      opts[:root] = Pathname(__FILE__).join("../../..").realpath.dirname

      use Rack::Session::Cookie, key: "<%= config[:underscored_umbrella_name] %>.<%= config[:underscored_project_name] %>.session", secret: self["core.settings"].session_secret
      use Rack::MethodOverride

      plugin :csrf, raise: true
      plugin :dry_view
      plugin :error_handler
      plugin :flash
      plugin :multi_route
      plugin :all_verbs

      route do |r|
        # Enable this after writing your first web/routes/ file
        # r.multi_route

        r.root do
          r.view :welcome
        end
      end

      # Request-specific options for dry-view context object
      def view_context_options
        {
          flash:        flash,
          csrf_token:   Rack::Csrf.token(request.env),
          csrf_metatag: Rack::Csrf.metatag(request.env),
          csrf_tag:     Rack::Csrf.tag(request.env),
        }
      end

      load_routes!
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-web-roda-0.14.0 lib/dry/web/roda/templates/subapp/web.rb.tt
dry-web-roda-0.13.1 lib/dry/web/roda/templates/subapp/web.rb.tt
dry-web-roda-0.13.0 lib/dry/web/roda/templates/subapp/web.rb.tt
dry-web-roda-0.12.0 lib/dry/web/roda/templates/subapp/web.rb.tt