{"record":{"id":"987c922bccbf1063","repo":"socketry/falcon","slug":"falcon-server-middleware-is-deprecated-use-r","errorCode":null,"errorMessage":"`Falcon::Server.middleware` is deprecated, use `.rack_middleware` instead.","messagePattern":"`Falcon::Server\\.middleware` is deprecated, use `\\.rack_middleware` instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"lib/falcon/server.rb","lineNumber":22,"sourceCode":"# Copyright, 2017-2026, by Samuel Williams.\n\nrequire \"async/http/server\"\n\nrequire \"protocol/http/middleware/builder\"\nrequire \"protocol/http/content_encoding\"\n\nrequire \"async/http/cache\"\nrequire \"async/utilization\"\nrequire_relative \"body/request_finished\"\nrequire_relative \"middleware/verbose\"\nrequire \"protocol/rack\"\n\nmodule Falcon\n\t# A server listening on a specific endpoint, hosting a specific middleware.\n\tclass Server < Async::HTTP::Server\n\t\t# @deprecated Use {rack_middleware} instead.\n\t\tdef self.middleware(...)\n\t\t\twarn(\"`Falcon::Server.middleware` is deprecated, use `.rack_middleware` instead.\", uplevel: 1, category: :deprecated) if $VERBOSE\n\t\t\t\n\t\t\treturn self.rack_middleware(...)\n\t\tend\n\t\t\n\t\t# Wrap a Rack application with the standard server middleware.\n\t\t# @parameter rack_app [Proc | Object] A rack application/middleware.\n\t\t# @parameter verbose [Boolean] Whether to add the {Middleware::Verbose} middleware.\n\t\t# @parameter cache [Boolean] Whether to add the {Async::HTTP::Cache} middleware.\n\t\tdef self.rack_middleware(rack_app, verbose: false, cache: true)\n\t\t\treturn self.protocol_middleware(::Protocol::Rack::Adapter.new(rack_app), verbose: verbose, cache: cache)\n\t\tend\n\t\t\n\t\t# Wrap a protocol application with the standard server middleware.\n\t\t# @parameter application [Protocol::HTTP::Middleware] The protocol application/middleware.\n\t\t# @parameter verbose [Boolean] Whether to add the {Middleware::Verbose} middleware.\n\t\t# @parameter cache [Boolean] Whether to add the {Async::HTTP::Cache} middleware.\n\t\tdef self.protocol_middleware(application, verbose: false, cache: true)\n\t\t\t::Protocol::HTTP::Middleware.build do","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/socketry/falcon/blob/5107b0713fd78dbe8b08ee123391b1f4bcffdf12/lib/falcon/server.rb#L4-L40","documentation":"Falcon::Server.middleware is a deprecated compatibility alias that forwards to rack_middleware (lib/falcon/server.rb:21-25). Calling it still works, but it emits a Ruby deprecation warning — only when $VERBOSE is set — pointing at the new name. The rename reflects the split between rack_middleware, which wraps a Rack application via Protocol::Rack::Adapter, and protocol_middleware, which wraps a Protocol::HTTP middleware directly.","triggerScenarios":"Calling Falcon::Server.middleware(rack_app, verbose:, cache:) in initializers, service definitions, or gems written against older falcon; the warning text becomes visible when the process runs with warnings enabled (ruby -w, RUBYOPT=-W, or Warning[:deprecated] = true).","commonSituations":"Upgrading falcon to a release that introduced the rack_middleware/protocol_middleware split; third-party middleware gems, templates, or tutorials still using the old name; CI setups that escalate warnings (-W) or treat deprecations as failures.","solutions":["Replace calls: Falcon::Server.middleware(app) -> Falcon::Server.rack_middleware(app)","For Protocol::HTTP (non-Rack) applications use Falcon::Server.protocol_middleware(application)","If the call site is a dependency, upgrade that gem or report the rename upstream"],"exampleFix":"# before\nmiddleware = Falcon::Server.middleware(rack_app, verbose: true, cache: true)\n# warning: `Falcon::Server.middleware` is deprecated, use `.rack_middleware` instead.\n\n# after\nmiddleware = Falcon::Server.rack_middleware(rack_app, verbose: true, cache: true)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"# Feature-detect the renamed class method before calling it.\ndef build_falcon_middleware(rack_app, **options)\n  name = Falcon::Server.respond_to?(:rack_middleware) ? :rack_middleware : :middleware\n  Falcon::Server.public_send(name, rack_app, **options)\nend","tryCatchPattern":null,"preventionTips":["Run specs with ruby -w (or RUBYOPT=-W) so deprecations surface before they become removals","After upgrading falcon, grep your code and dependencies for Falcon::Server.middleware","Adopt rack_middleware / protocol_middleware explicitly so Rack and Protocol::HTTP apps use the right wrapper"],"tags":["falcon","deprecation","middleware","ruby"],"backgroundTag":"deprecated-api-usage","analyzedSha":"5107b0713fd78dbe8b08ee123391b1f4bcffdf12","analyzedAt":"2026-08-23T14:31:56.885Z","schemaVersion":2},"datasetVersion":"2026-08-23T16:17:53.355Z"}