Sha256: 4fc8f7bc3ab40cb96f1e604fb7f03fd7deb074b0763b8c266d17c59e38812918

Contents?: true

Size: 845 Bytes

Versions: 1

Compression:

Stored size: 845 Bytes

Contents

module Lita
  module Handlers
    # HTTP-related handlers
    class LockerHttp < Handler
      namespace 'Locker'

      include ::Locker::Label
      include ::Locker::Misc
      include ::Locker::Regex
      include ::Locker::Resource

      http.get '/locker/label/:name', :http_label_show
      http.get '/locker/resource/:name', :http_resource_show

      def http_label_show(request, response)
        name = request.env['router.params'][:name]
        response.headers['Content-Type'] = 'application/json'
        response.write(label(name).to_json)
      end

      def http_resource_show(request, response)
        name = request.env['router.params'][:name]
        response.headers['Content-Type'] = 'application/json'
        response.write(resource(name).to_json)
      end

      Lita.register_handler(LockerHttp)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-locker-0.7.0 lib/lita/handlers/locker_http.rb