public OwinLayimContext(LayimStorage storage, LayimOptions options, IDictionary <string, object> environment) : base(storage, options) { Error.ThrowIfNull(environment, nameof(environment)); Request = new OwinLayimRequest(environment); Response = new OwinLayimResponse(environment); }
public static MidFunc UseLayimApi(LayimStorage storage, LayimOptions options, RouteCollection routes) { Error.ThrowIfNull(options, nameof(options)); Error.ThrowIfNull(routes, nameof(routes)); return(next => env => { var owinContext = new OwinContext(env); var context = new OwinLayimContext(storage, options, env); var path = owinContext.Request.Path.Value; //匹配路由 var findResult = routes.FindDispatcher(path); //如果没有匹配到,执行下一个 if (findResult == null) { return next(env); } //匹配成功之后执行 Dispatch context.UriMatch = findResult.Item2; //执行具体disptach方法,返回相应结果 return findResult.Item1.Dispatch(context); }); }
protected LayimContext(LayimStorage storage, LayimOptions options) { Error.ThrowIfNull(storage, nameof(storage)); Error.ThrowIfNull(options, nameof(options)); Storage = storage; Options = options; }
/// <summary> /// 自定义其他设置 /// </summary> /// <param name="builder"></param> /// <param name="pathMatch"></param> /// <param name="options"></param> /// <returns></returns> public static IAppBuilder UseLayimApi(this IAppBuilder builder, string pathMatch, LayimOptions options, LayimStorage storage) { Error.ThrowIfNull(pathMatch, nameof(pathMatch)); Error.ThrowIfNull(options, nameof(options)); SignatureConversions.AddConversions(builder); builder.Map(pathMatch, appBuilder => appBuilder .UseOwin() .UseLayimApi(storage, options, LayimRoutes.Routes)); return(builder); }
public static BuildFunc UseLayimApi(this BuildFunc builder, LayimStorage storage, LayimOptions options, RouteCollection routes) { builder(_ => UseLayimApi(storage, options, routes)); return(builder); }
public LayimUserClient(LayimStorage storage, long id) { _storage = storage; _id = id; }
public LayimUserClient(LayimStorage storage, LayimRequest request) : this(storage, 0) { _request = request; }