Sha256: 2244910d9b817bdd1585a7554f76d9d851ea7a2cd52de647be61fe2bfa2121b4

Contents?: true

Size: 1.03 KB

Versions: 11

Compression:

Stored size: 1.03 KB

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', :label_show
      http.get '/locker/resource/:name', :resource_show

      def label_show(request, response)
        name = request.env['router.params'][:name]
        response.headers['Content-Type'] = 'application/json'
        unless Label.exists?(name)
          response.status = 404
          return
        end
        l = Label.new(name)
        response.write(l.to_json)
      end

      def resource_show(request, response)
        name = request.env['router.params'][:name]
        response.headers['Content-Type'] = 'application/json'
        unless Resource.exists?(name)
          response.status = 404
          return
        end
        r = Resource.new(name)
        response.write(r.to_json)
      end

      Lita.register_handler(LockerHttp)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
lita-locker-1.0.10 lib/lita/handlers/locker_http.rb
lita-locker-1.0.9 lib/lita/handlers/locker_http.rb
lita-locker-1.0.8 lib/lita/handlers/locker_http.rb
lita-locker-1.0.7 lib/lita/handlers/locker_http.rb
lita-locker-1.0.6 lib/lita/handlers/locker_http.rb
lita-locker-1.0.5 lib/lita/handlers/locker_http.rb
lita-locker-1.0.4 lib/lita/handlers/locker_http.rb
lita-locker-1.0.3 lib/lita/handlers/locker_http.rb
lita-locker-1.0.2 lib/lita/handlers/locker_http.rb
lita-locker-1.0.1 lib/lita/handlers/locker_http.rb
lita-locker-1.0.0 lib/lita/handlers/locker_http.rb