Skip to content

Drop support for local middleware/adapter functions #171

@teamon

Description

@teamon

TODO

  • Remove support for local middleware
  • Remove support for local adapter
  • Keep support for anon fun adapter
  • Remove all references in docs (plug)
  • Add info to migration guide
  • Add test to migration test

Context

What is local middleware?

defmodule Client do
  use Tesla
  plug :some_local_function

  def some_local_function(env, next) do
    # ...
  end
end

Pros

  • No need to create a separate module for something trivial

Cons

  • Additional complexity
  • Conflicting API with now-removed aliases support
  • The function must be public anyway

The local middleware can be replaced with simply module:

defmodule Client do
  defmodule LocalMiddleware do
    def call(env, next, _opts) do
      # ...
    end
  end

  use Tesla
  plug LocalMiddleware
end

Question

Is local function middleware widely used or not?

/cc @amatalai @hodak @any-other-tesla-user

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions