Sha256: 461db34628ff7548698913dcfde736ba8f7a4a6888c2565f0d81a53476fc5229

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2024 Eric Crane.  All rights reserved.
#
# Redirect the web svr request to a different page.
# This verb only works in context of a running web server.
#

module Gloo
  module Verbs
    class Redirect < Gloo::Core::Verb

      KEYWORD = 'redirect'.freeze
      KEYWORD_SHORT = 'go'.freeze

      MISSING_EXPR_ERR = 'Missing Expression!'.freeze

      #
      # Run the verb.
      #
      def run
        if @tokens.token_count < 2
          @engine.err MISSING_EXPR_ERR
          return
        end

        # Send the redirect page to the running app.
        if @engine.app_running?
          obj_name = @tokens.second
          pn = Gloo::Core::Pn.new( @engine, obj_name )
          @engine.running_app.obj.redirect = pn.resolve
        end
      end

      #
      # Get the Verb's keyword.
      #
      def self.keyword
        return KEYWORD
      end

      #
      # Get the Verb's keyword shortcut.
      #
      def self.keyword_shortcut
        return KEYWORD_SHORT
      end

      # ---------------------------------------------------------------------
      #    Private functions
      # ---------------------------------------------------------------------

      private

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gloo-3.1.1 lib/gloo/verbs/redirect.rb
gloo-3.1.0 lib/gloo/verbs/redirect.rb