Sha256: 7f40bbe8651d6a81174820ffaad895571d051df2911b82bcd43f701b07aafd00

Contents?: true

Size: 909 Bytes

Versions: 6

Compression:

Stored size: 909 Bytes

Contents

require 'sinatra/base'

module Voom
  module Presenters
    module Demo
      # Echo's back post, delete and put
      # Used to demonstrate how the posts(updates), deletes and modifies actions work.
      class Echo < Sinatra::Base
        post('/_echo_') do
          content_type :json
          params[:echo] = JSON.parse(params[:echo]) if params[:echo]
          status(params[:status]) if params[:status]
          JSON.dump(params)
        end

        post('/_echo_snackbar_') do
          content_type :json
          JSON.dump(messages:{snackbar: [params[:snackbar_echo]]})
        end

        delete('/_echo_') do
          content_type :json
          JSON.dump(params)
        end

        put('/_echo_') do
          content_type :json
          JSON.dump(params)
        end

        # start the server if ruby file executed directly
        run! if app_file == $0
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
voom-presenters-2.1.2 lib/voom/presenters/demo/echo.rb
voom-presenters-2.1.0 lib/voom/presenters/demo/echo.rb
voom-presenters-2.0.3 lib/voom/presenters/demo/echo.rb
voom-presenters-2.0.2 lib/voom/presenters/demo/echo.rb
voom-presenters-2.0.1 lib/voom/presenters/demo/echo.rb
voom-presenters-2.0.0 lib/voom/presenters/demo/echo.rb