import functools


def middleware(f):
  """Function decorator for making WSGI middlewares."""
  return functools.update_wrapper(
      lambda app: lambda wsgi_env, start_resp: f(app, wsgi_env, start_resp),
      f)