|
131 | 131 | { |
132 | 132 | "data": { |
133 | 133 | "text/plain": [ |
134 | | - "datetime.datetime(2024, 12, 10, 14, 0)" |
| 134 | + "datetime.datetime(2024, 12, 20, 14, 0)" |
135 | 135 | ] |
136 | 136 | }, |
137 | 137 | "execution_count": null, |
|
2423 | 2423 | "name": "stdout", |
2424 | 2424 | "output_type": "stream", |
2425 | 2425 | "text": [ |
2426 | | - "Set to 2024-12-10 09:54:42.331681\n" |
| 2426 | + "Set to 2024-12-20 19:21:33.748637\n" |
2427 | 2427 | ] |
2428 | 2428 | }, |
2429 | 2429 | { |
2430 | 2430 | "data": { |
2431 | 2431 | "text/plain": [ |
2432 | | - "'Session time: 2024-12-10 09:54:42.331681'" |
| 2432 | + "'Session time: 2024-12-20 19:21:33.748637'" |
2433 | 2433 | ] |
2434 | 2434 | }, |
2435 | 2435 | "execution_count": null, |
|
2636 | 2636 | "#| export\n", |
2637 | 2637 | "class APIRouter:\n", |
2638 | 2638 | " \"Add routes to an app\"\n", |
2639 | | - " def __init__(self, prefix:str|None=None): \n", |
| 2639 | + " def __init__(self, prefix:str|None=None, body_wrap=noop_body): \n", |
2640 | 2640 | " self.routes,self.wss = [],[]\n", |
2641 | 2641 | " self.rt_funcs = RouteFuncs() # Store wrapped route function for discoverability\n", |
2642 | 2642 | " self.prefix = prefix if prefix else \"\"\n", |
| 2643 | + " self.body_wrap = body_wrap\n", |
2643 | 2644 | "\n", |
2644 | 2645 | " def _wrap_func(self, func, path=None):\n", |
2645 | 2646 | " name = func.__name__\n", |
|
2649 | 2650 | " if name not in all_meths: setattr(self.rt_funcs, name, wrapped)\n", |
2650 | 2651 | " return wrapped\n", |
2651 | 2652 | "\n", |
2652 | | - " def __call__(self, path:str=None, methods=None, name=None, include_in_schema=True, body_wrap=noop_body):\n", |
| 2653 | + " def __call__(self, path:str=None, methods=None, name=None, include_in_schema=True, body_wrap=None):\n", |
2653 | 2654 | " \"Add a route at `path`\"\n", |
2654 | 2655 | " def f(func):\n", |
2655 | 2656 | " p = self.prefix + (\"/\" + ('' if path.__name__=='index' else func.__name__) if callable(path) else path)\n", |
2656 | 2657 | " wrapped = self._wrap_func(func, p)\n", |
2657 | | - " self.routes.append((func, p, methods, name, include_in_schema, body_wrap))\n", |
| 2658 | + " self.routes.append((func, p, methods, name, include_in_schema, body_wrap or self.body_wrap))\n", |
2658 | 2659 | " return wrapped\n", |
2659 | 2660 | " return f(path) if callable(path) else f\n", |
2660 | 2661 | " \n", |
|
2949 | 2950 | { |
2950 | 2951 | "data": { |
2951 | 2952 | "text/plain": [ |
2952 | | - "'Cookie was set at time 09:54:43.255286'" |
| 2953 | + "'Cookie was set at time 19:21:34.644743'" |
2953 | 2954 | ] |
2954 | 2955 | }, |
2955 | 2956 | "execution_count": null, |
|
0 commit comments