MCPcopy Create free account
hub / github.com/dot-agent/nextpy / postprocess

Method postprocess

nextpy/app.py:295–322  ·  view source on GitHub ↗

Postprocess the event. This is where middleware can modify the delta after it is processed. Each middleware is called in the order it was added to the app. Args: state: The state to postprocess. event: The event to postprocess. update: Th

(
        self, state: BaseState, event: Event, update: StateUpdate
    )

Source from the content-addressed store, hash-verified

293 return out # type: ignore
294
295 async def postprocess(
296 self, state: BaseState, event: Event, update: StateUpdate
297 ) -> StateUpdate:
298 """Postprocess the event.
299
300 This is where middleware can modify the delta after it is processed.
301 Each middleware is called in the order it was added to the app.
302
303 Args:
304 state: The state to postprocess.
305 event: The event to postprocess.
306 update: The current state update.
307
308 Returns:
309 The state update to return.
310 """
311 for middleware in self.middleware:
312 if asyncio.iscoroutinefunction(middleware.postprocess):
313 out = await middleware.postprocess(
314 app=self, state=state, event=event, update=update # type: ignore
315 )
316 else:
317 out = middleware.postprocess(
318 app=self, state=state, event=event, update=update # type: ignore
319 )
320 if out is not None:
321 return out # type: ignore
322 return update
323
324 def add_middleware(self, middleware: Middleware, index: int | None = None):
325 """Add middleware to the app.

Callers 3

_coroMethod · 0.95
processFunction · 0.45
_ndjson_updatesFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected