public static string GetMethodDetails(HttpController controller, HttpEndpoint endpoint, bool async, bool raw) { var cancellationToken = endpoint.GetRequestModifiers().OfType <CancellationTokenModifier>().SingleOrDefault(); var clientDependency = new ClientDependency($"I{Settings.ClientInterfaceName}Wrapper"); var requestModifiers = endpoint.GetRequestModifiers().ToList(); var bodyParameter = endpoint.GetBodyParameter(); string bodyVariable = bodyParameter?.Name ?? "null"; var responseTypes = endpoint.GetResponseTypes(); var routeConstraints = endpoint.GetRouteConstraints(controller); return ($@"{string.Join(Environment.NewLine, routeConstraints.Select(WriteRouteConstraint).NotNull())} {GetEndpointInfoVariables(controller, endpoint)} string url = $@""{GetRoute(controller, endpoint, async)}""; HttpResponseMessage response = null; response = {GetAwait(async)}HttpOverride.GetResponseAsync({GetHttpMethod(endpoint.HttpType)}, url, null, {cancellationToken.Name}){GetAsyncEnding(async)}; if(response == null) {{ try {{ response = {GetAwait(async)}{clientDependency.GetDependencyName($"I{Settings.ClientInterfaceName}")}.{nameof(IClientWrapper.ClientWrapper)} .Request(url) {string.Join($" {Environment.NewLine}", requestModifiers.Select(WriteRequestModifiers).NotNull())} .AllowAnyHttpStatus() {GetHttpMethod(endpoint)} {GetAsyncEnding(async)}; }} catch({nameof(FlurlHttpException)} fhex) {{ {WriteResponseType(responseTypes.OfType<ExceptionResponseType>().Single(), async, false)} {WriteErrorActionResultReturn(endpoint, async, raw)} }} {GetAwait(async)}HttpOverride.OnNonOverridedResponseAsync({GetHttpMethod(endpoint.HttpType)}, url, {bodyVariable}, response, {cancellationToken.Name}){GetAsyncEnding(async)}; }} {string.Join(Environment.NewLine, responseTypes.Where(x => x.GetType() != typeof(ExceptionResponseType)).Select(x => WriteResponseType(x, async, raw)).NotNull())} {WriteActionResultReturn(endpoint, async, raw)}"); }