public override Task Process(HttpContext context) { var tokenHeader = ((Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameRequestHeaders)context.Request.Headers) .HeaderAuthorization; var token = tokenHeader.ToString().Replace("Bearer", string.Empty).Trim(); _user = LoginUtil.GetToken(token)?.Username; return(base.Process(context)); }
public override IDefaultAudio GetAudio(string key) { var split = key.Split('_'); var user = LoginUtil.GetToken(split[0]); if (user == null) { return(null); } var bookKey = split[1]; if (!AudioCache.ContainsKey(bookKey)) { var book = UserContext.GetShallow <Book>(new Id(bookKey)); var audio = new Audio(book); AudioCache.Add(bookKey, audio); return(AudioCache[bookKey]); } return(AudioCache[bookKey]); }