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

Method preprocess

nextpy/app.py:271–293  ·  view source on GitHub ↗

Preprocess the event. This is where middleware can modify the event before it is processed. Each middleware is called in the order it was added to the app. If a middleware returns an update, the event is not processed and the update is returned. Args:

(self, state: BaseState, event: Event)

Source from the content-addressed store, hash-verified

269 return self._state_manager
270
271 async def preprocess(self, state: BaseState, event: Event) -> StateUpdate | None:
272 """Preprocess the event.
273
274 This is where middleware can modify the event before it is processed.
275 Each middleware is called in the order it was added to the app.
276
277 If a middleware returns an update, the event is not processed and the
278 update is returned.
279
280 Args:
281 state: The state to preprocess.
282 event: The event to preprocess.
283
284 Returns:
285 An optional state to return.
286 """
287 for middleware in self.middleware:
288 if asyncio.iscoroutinefunction(middleware.preprocess):
289 out = await middleware.preprocess(app=self, state=state, event=event) # type: ignore
290 else:
291 out = middleware.preprocess(app=self, state=state, event=event) # type: ignore
292 if out is not None:
293 return out # type: ignore
294
295 async def postprocess(
296 self, state: BaseState, event: Event, update: StateUpdate

Callers 2

processFunction · 0.45

Calls

no outgoing calls

Tested by 1