路由
api.router.pas
/// <author>2024-1-25</author> unit api.router; interface uses global, net.CrossHttpServer, yn.log, Classes, StrUtils, SysUtils; type TMyProc = procedure(req: TRequest; res: TResponse) of object; procedure router(const className, funcName: string; req: TRequest; res: TResponse); /// 路由 implementation procedure router(const className, funcName: string; req: TRequest; res: TResponse); var m: TMethod; f: TMyProc; p: TPersistentClass; begin try p := FindClass(className); if p = nil then exit; m.Data := Pointer(p); m.Code := p.MethodAddress(funcName); if Assigned(m.Code) then begin f := TMyProc(m); f(req, res); end; except on E: Exception do begin WriteLog('api.router.router()' + E.Message); end; end; end; end.
router.json
{ "tables": [ { "classname":"TRESTtables", "method":"POST", "funcname":"select" } ], "danwei": [ { "classname":"TRESTdanwei", "method":"POST", "funcname":"select" }, { "classname":"TRESTdanwei", "method":"POST", "funcname":"select2" }, { "classname":"TRESTdanwei", "method":"POST", "funcname":"insert" }, { "classname":"TRESTdanwei", "method":"POST", "funcname":"update" }, { "classname":"TRESTdanwei", "method":"POST", "funcname":"delete" } ], "multipart": [ { "classname":"TRESTmultipart", "method":"POST", "funcname":"downfile" }, { "classname":"TRESTmultipart", "method":"POST", "funcname":"upfile" } ], "bin": [ { "classname":"TBINolev", "method":"POST", "funcname":"select" }, { "classname":"TBINolev", "method":"POST", "funcname":"execsql" }, { "classname":"TBINolev", "method":"POST", "funcname":"save" }, { "classname":"TBINolev", "method":"POST", "funcname":"spopen" } ], "binfile": [ { "classname":"TBINfiletran", "method":"POST", "funcname":"upfile" }, { "classname":"TBINfiletran", "method":"POST", "funcname":"downfile" } ] }
标签:TRESTdanwei,funcname,classname,router,POST,method,路由 From: https://www.cnblogs.com/hnxxcxg/p/17986721