///
import Response from './response';
import { Info, ExtendedObject } from './info';
/** 路由函数 */
export interface ExecFunc {
/**
* @param data 数据
* @param info 相关信息
* @param response 相应
*/
(data: Data, info: Info, response: Response): undefined | Value | Response | Promise>;
}
/** 路由列表对象 */
export interface ExecObject {
_$?: ExecFunc;
_options?: ExecFunc;
_head?: ExecFunc;
_trace?: ExecFunc;
_get?: ExecFunc;
_post?: ExecFunc;
_put?: ExecFunc;
_delete?: ExecFunc;
_$$?: ExecFunc;
_$options?: ExecFunc;
_$head?: ExecFunc;
_$trace?: ExecFunc;
_$get?: ExecFunc;
_$post?: ExecFunc;
_$put?: ExecFunc;
_$delete?: ExecFunc;
_?: ExecFunc;
[key: string]: undefined | ExecFunc | ExecObject;
}
/** 路由 */
export interface Router {
/**
* @param path 路径数组
* @param method 执行方法
* @param restful restful 数据,如果传入,则一定当 restful 处理
*/
(p: string[], method?: string, restful?: object, ...m: any[]): IterableIterator>;
}
/** 自定义路由 */
export interface ExecHandle {
/**
* @param path 路径数组
* @param func 路由
* @param method 执行方法
* @param restful restful 数据,如果传入,则一定当 restful 处理
*/
(p: string[], f: Router, method?: string, restful?: object, ...m: any[]): IterableIterator>;
}
/** 路由创建函数 */
interface create {
/**
* 创建函数路由
* @param object 函数集合
* @param handle 自定义处理器
*/
(object: ExecObject, handle?: ExecHandle): Router;
}
/**
* 创建函数路由
* @param object 函数集合
* @param handle 自定义处理器
*/
declare function create(object: ExecObject, handle?: ExecHandle): Router;
export default create;