Sha256: 617d88d47793ca80cb7e1e714163a7728a5794f69073fdc2e0143ff2f18ae4db

Contents?: true

Size: 929 Bytes

Versions: 4

Compression:

Stored size: 929 Bytes

Contents

class Tynn
  # Public: Adds method for HTTP's +HEAD+ and +OPTIONS+.
  #
  # Examples
  #
  #   require "tynn"
  #   require "tynn/all_methods"
  #
  #   Tynn.plugin(Tynn::AllMethods)
  #
  module AllMethods
    module InstanceMethods
      # Public: Executes the given block if the request method is +HEAD+.
      #
      # Examples
      #
      #   Tynn.define do
      #     head do
      #       res.status = 201
      #     end
      #   end
      #
      def head
        if root? && req.head?
          yield

          halt(res.finish)
        end
      end

      # Public: Executes the given block if the request method is +OPTIONS+.
      #
      # Examples
      #
      #   Tynn.define do
      #     options do
      #       res.status = 405
      #     end
      #   end
      #
      def options
        if root? && req.options?
          yield

          halt(res.finish)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tynn-1.4.0 lib/tynn/all_methods.rb
tynn-1.3.0 lib/tynn/all_methods.rb
tynn-1.2.0 lib/tynn/all_methods.rb
tynn-1.1.0 lib/tynn/all_methods.rb