/// <summary> /// 创建基本的通用数据 /// </summary> /// <param name="context">上下文</param> /// <param name="key">键</param> /// <param name="menuCode">菜单编码</param> /// <param name="authToken">授权票据</param> /// <param name="functionCodes">功能编码数组</param> /// <returns>基本的通用数据</returns> public static CommonUseData CreateBasicCommonUseData(this HttpContext context, string key = null, string menuCode = null, IAuthToken authToken = null, params string[] functionCodes) { var result = new CommonUseData() { Key = key, MenuCode = menuCode, FunctionCodes = functionCodes }; if (context != null && context.Request != null) { result.Path = context.Request.Path.Value.ToLower(); var routeValue = context.Request.RouteValues; var routes = routeValue.GetControllerAction(); if (routes != null && routes.Length > 1) { result.Controller = routes[0]; result.Action = routes[1]; } result.Token = authToken == null?context.Request.GetBearerOriginTokenFromHeader() : authToken.GetToken(); if (context.Request.Headers != null && context.Request.Headers.ContainsKey(App.EVENT_ID_KEY)) { result.EventId = context.Request.Headers[App.EVENT_ID_KEY]; } result.CommMode = GRpcChannelUtil.IsRequestGRpc(context.Request.ContentType) ? CommunicationMode.GRPC : CommunicationMode.HTTP; } return(result); }
private string AuthHeader() { return("Bearer " + _authToken.GetToken()); }