public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "graphql")] HttpRequestMessage reqMessage, HttpRequest req, ExecutionContext context, ILogger log) { var httpContextAccessor = FunctionStartup.EstablishHttpContextAccessor(context, reqMessage, req); FunctionStartup.EstablishContextAccessor(context); await FunctionStartup.EstablishIdentityAsync(context, httpContextAccessor); var factory = FunctionStartup.GetFactory(context); var functionHandler = factory.Create <IGraphQLFunction>(); await functionHandler.InvokeAsync(); return(httpContextAccessor.HttpResponseMessage); /* * * var tokenValidator = factory.ServiceProvider.GetService(typeof(ITokenValidator)) as ITokenValidator; * httpContextAccessor.HttpContext.User = await tokenValidator.ValidateTokenAsync(reqMessage.Headers.Authorization); ; * * if (httpContextAccessor.HttpContext.User == null) * { * return reqMessage.CreateResponse(HttpStatusCode.Unauthorized); * } * // Authentication boilerplate code end * * return reqMessage.CreateResponse(HttpStatusCode.OK, "Hello " + httpContextAccessor.HttpContext.User.Identity.Name); */ }
public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "authority/{*all}")] HttpRequestMessage reqMessage, HttpRequest req, ExecutionContext context, ILogger log) { var httpContextAccessor = FunctionStartup.EstablishHttpContextAccessor(context, reqMessage, req); FunctionStartup.EstablishContextAccessor(context); var factory = FunctionStartup.GetFactory(context); var functionHandler = factory.Create <IAuthorityFunction>(); await functionHandler.InvokeAsync(); return(httpContextAccessor.HttpResponseMessage); }