|
7 | 7 | 'charset', 'cors_allow', 'iframe_scr', 'all_meths', 'parsed_date', 'snake2hyphens', 'HtmxHeaders', |
8 | 8 | 'HttpHeader', 'HtmxResponseHeaders', 'form2dict', 'parse_form', 'flat_xt', 'Beforeware', 'EventStream', |
9 | 9 | 'signal_shutdown', 'uri', 'decode_uri', 'flat_tuple', 'noop_body', 'respond', 'Redirect', 'get_key', 'qp', |
10 | | - 'def_hdrs', 'FastHTML', 'serve', 'Client', 'RouteFuncs', 'APIRouter', 'cookie', 'reg_re_param', |
11 | | - 'MiddlewareBase', 'FtResponse', 'unqid', 'setup_ws'] |
| 10 | + 'def_hdrs', 'FastHTML', 'nested_name', 'serve', 'Client', 'RouteFuncs', 'APIRouter', 'cookie', |
| 11 | + 'reg_re_param', 'MiddlewareBase', 'FtResponse', 'unqid', 'setup_ws'] |
12 | 12 |
|
13 | 13 | # %% ../nbs/api/00_core.ipynb |
14 | 14 | import json,uuid,inspect,types,uvicorn,signal,asyncio,threading,inspect |
@@ -597,10 +597,15 @@ def to(self, **kw): return qp(p, **kw) |
597 | 597 | def __str__(self): return p |
598 | 598 | return _lf() |
599 | 599 |
|
| 600 | +# %% ../nbs/api/00_core.ipynb |
| 601 | +def nested_name(f): |
| 602 | + "Get name of function `f` using '_' to join nested function names" |
| 603 | + return f.__qualname__.replace('.<locals>.', '_') |
| 604 | + |
600 | 605 | # %% ../nbs/api/00_core.ipynb |
601 | 606 | @patch |
602 | 607 | def _add_route(self:FastHTML, func, path, methods, name, include_in_schema, body_wrap): |
603 | | - n,fn,p = name,func.__name__,None if callable(path) else path |
| 608 | + n,fn,p = name,nested_name(func),None if callable(path) else path |
604 | 609 | if methods: m = [methods] if isinstance(methods,str) else methods |
605 | 610 | elif fn in all_meths and p is not None: m = [fn] |
606 | 611 | else: m = ['get','post'] |
|
0 commit comments