New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mediate

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mediate

Middleware for every occasion

  • 0.1.8
  • PyPI
  • Socket score

Maintainers
1

mediate

Middleware for every occasion

Installation

mediate can be installed from PyPI

pip install mediate

Usage

@middleware

from mediate import middleware

def shout(call_next, name):
    return call_next(name.upper())

def exclaim(call_next, name):
    return call_next(name + "!")

@middleware(shout, exclaim)
def hello(name):
    print(f"Hello, {name}")
>>> hello("sam")
Hello, SAM!

Middleware

Middleware.bind
import mediate

middleware = mediate.Middleware()

@middleware
def shout(call_next, name):
    return call_next(name.upper())

@middleware
def exclaim(call_next, name):
    return call_next(name + "!")

@middleware.bind
def hello(name):
    print(f"Hello, {name}")
>>> hello("sam")
Hello, SAM!
Middleware.compose
import mediate

middleware = mediate.Middleware()

@middleware
def shout(call_next, name):
    return call_next(name.upper())

@middleware
def exclaim(call_next, name):
    return call_next(name + "!")

def hello(name):
    print(f"Hello, {name}")

composed_hello = middleware.compose(hello)
>>> hello("sam")
Hello, sam
>>> composed_hello("sam")
Hello, SAM!

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc