Module deriv_api.middlewares

Classes

class MiddleWares (middlewares={})

A class that help to manage middlewares

Examples

middlewares = MiddleWares() middlewares.add('sendWillBeCalled', lanmbda req: print(req)) middlewares = Middlewares({'sendWillBeCalled': lambda req: print(req)}) middleware->call('sendWillBeCalled', arg1, arg2)

Parameters

options: dict with following key value pairs key: string, middleware name value: function, middleware code

Methods

def add(self, name, code)

Add middleware

Parameters

name: Str middleware name code: function middleware code

def call(self, name, args)

Call middleware and return the result if there is such middleware

Parameters

name : string
 
args : list
the args that will feed to middleware

Returns

If there is such middleware, then return the result of middleware
else return None