Sha256: 286d02e206b24ceff21e3a617a531f31bc86a042d16294933547ba82f8397921
Contents?: true
Size: 916 Bytes
Versions: 7
Compression:
Stored size: 916 Bytes
Contents
module Apiture module Middleware module Auth class APIKey def initialize(app, options) @app = app @id = options[:id] @in = options[:in] @name = options[:name] @format = options[:format] end def call(env) context = env[:context] value = format_value(context.options[@id]) if @in == :header env[:request_headers][@name] = value elsif @in == :query env[:params][@name] = value elsif @in == :body env[:body] = if body = env[:body] body.merge(@name => value) else { @name => value } end end @app.call(env) end protected def format_value(val) return val unless @format @format % val end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems