public Task HandleRequest(HttpParameter parameter, HttpRequest request)
 {
     try
     {
         //Get all attributed headers
         var headerList = Headers.GetOrAdd(parameter.GetType(), HandleType);
         headerList.ForEach(header => request.AddHeader(header.Key, header.Value));
         return(Task.FromResult(true));
     }
     catch (Exception e)
     {
         Error(e);
         return(Task.FromResult(false));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        ///     Add Authorization header to the <see cref="HttpRequest" />
        /// </summary>
        /// <param name="parameter">The parameter for the request</param>
        /// <param name="request">The http request</param>
        public async Task HandleRequest(HttpParameter parameter, HttpRequest request)
        {
            try
            {
                var requireAuth = AuthTypes.GetOrAdd(parameter.GetType(), HandleType);
                if (requireAuth)
                {
                    var accessToken = await AuthorizationService.GetAccessToken();

                    request.AddHeader("Authorization", $"Bearer {accessToken}");
                }
            }
            catch (Exception e)
            {
                Error(e);
            }
        }