class THTP::NullRoute

A THTP middleware stack terminator, telling clients they've done something wrong if their requests weren't captured by a running server

Public Instance Methods

call(env) click to toggle source

if a request makes it here, it's bad; tell the caller what it should have done

# File lib/thtp/server/null_route.rb, line 14
def call(env)
  # default to CompactProtocol because we need a protocol with which to send back errors
  protocol = Encoding.protocol(Rack::Request.new(env).media_type) || Thrift::JsonProtocol
  headers = { Rack::CONTENT_TYPE => Encoding.content_type(protocol) }
  body = Utils.serialize_buffer(BadRequestError.new.to_thrift, protocol)
  [Status::EXCEPTION, headers, [body]]
end