public static string ToAbsoluteUri(this IReturn requestDto, string httpMethod = null, string formatFallbackToPredefinedRoute = null) { var relativeUrl = requestDto.ToUrl( httpMethod ?? HttpMethods.Get, formatFallbackToPredefinedRoute ?? HostContext.Config.DefaultContentType.ToContentFormat()); return(relativeUrl.ToAbsoluteUri()); }
protected Uri UriFor(IReturn request, Http method) { string json = EndpointHostConfig.Instance.ServiceEndpointsMetadataConfig.Json.Format; string url = request.ToUrl(method.ToString().ToUpperInvariant(), ""); url = url.Replace("//", "/" + json + "/"); return(UriFor(url)); }
public virtual Task <TResponse> CustomMethodAsync <TResponse>(string httpVerb, IReturn <TResponse> requestDto) { if (!HttpMethods.HasVerb(httpVerb)) { throw new NotSupportedException("Unknown HTTP Method is not supported: " + httpVerb); } return(asyncClient.SendAsync <TResponse>(httpVerb, GetUrl(requestDto.ToUrl(httpVerb, Format)), requestDto)); }
public static string ToAbsoluteUri(this IReturn request, string httpMethod = null, string formatFallbackToPredefinedRoute = null) { var relativeUrl = request.ToUrl( httpMethod ?? HttpMethods.Get, formatFallbackToPredefinedRoute ?? EndpointHost.Config.DefaultContentType.ToContentFormat()); var absoluteUrl = EndpointHost.Config.WebHostUrl.CombineWith(relativeUrl); return(absoluteUrl); }
public static Link Link(this IAppHost host, string rel, IReturn dto, string method) { string path = host.Config.ServiceStackHandlerFactoryPath; return(new Link { Rel = rel, Method = method, Href = new Uri("/".CombineWith(path, dto.ToUrl(method)), UriKind.Relative) }); }
public Task <TResponse> CustomMethodAsync <TResponse>(string httpVerb, IReturn <TResponse> requestDto) { if (!HttpMethods.HasVerb(httpVerb)) { throw new NotSupportedException("Unknown HTTP Method is not supported: " + httpVerb); } var requestBody = httpVerb.HasRequestBody() ? requestDto : null; return(SendAsync <TResponse>(httpVerb, GetBaseUrl(requestDto.ToUrl(httpVerb, Format)), requestBody)); }
public T Send <T>(IReturn <T> request, string method, bool sendRequestBody = true, string idempotencyKey = null) { using (new ConfigScope()) { var relativeUrl = request.ToUrl(method); var body = sendRequestBody ? QueryStringSerializer.SerializeToString(request) : null; var json = Send(relativeUrl, method, body, idempotencyKey); var response = json.FromJson <T>(); return(response); } }
public T Send <T>(IReturn <T> request, string method, bool sendRequestBody = true) { using (new ConfigScope()) { var relativeUrl = request.ToUrl(method); var body = sendRequestBody ? JsonSerializer.SerializeToString(request) : null; var json = this.Send(relativeUrl, method, body); var response = json.FromJson <T>(); return(response); } }
public static Task <TResponse> PostAsync <TResponse>(this ServiceClientBase client, IReturn <TResponse> request) { var tcs = new TaskCompletionSource <TResponse>(); client.PostAsync <string>(request.ToUrl(HttpMethods.Post, client.Format), request, result => { var dto = Newtonsoft.Json.JsonConvert.DeserializeObject <TResponse>(result); tcs.SetResult(dto); }, (response, exception) => { Log.Debug("CMT Response Body : " + response + Environment.NewLine + Environment.NewLine + "Request : " + client.BaseUri + request.ToUrl(HttpMethods.Post, client.Format) + Environment.NewLine + request.ToJson() + Environment.NewLine + Environment.NewLine + "Exception : " + LogException(exception)); tcs.SetException(FixWebServiceException(exception)); } ); return(tcs.Task); }
public async Task <T> SendAsync <T>(IReturn <T> request, string method, bool sendRequestBody = true, string idempotencyKey = null) { string relativeUrl; string body; using (new ConfigScope()) { relativeUrl = request.ToUrl(method); body = sendRequestBody ? QueryStringSerializer.SerializeToString(request) : null; } var json = await SendAsync(relativeUrl, method, body, idempotencyKey); using (new ConfigScope()) { var response = json.FromJson <T>(); return(response); } }
public virtual TResponse Put <TResponse>(IReturn <TResponse> requestDto) { return(Put <TResponse>(requestDto.ToUrl(HttpMethods.Put, Format), requestDto)); }
public Task <TResponse> PutAsync <TResponse>(IReturn <TResponse> requestDto) { return(PutAsync <TResponse>(requestDto.ToUrl(HttpMethods.Put, Format), requestDto)); }
public Task <TResponse> DeleteAsync <TResponse>(IReturn <TResponse> requestDto) { return(DeleteAsync <TResponse>(requestDto.ToUrl(HttpMethods.Delete, Format))); }
public Task <TResponse> GetAsync <TResponse>(IReturn <TResponse> requestDto) { return(GetAsync <TResponse>(requestDto.ToUrl(HttpMethods.Get, Format))); }
public static string ToRelativeUri(this IReturn requestDto, string httpMethod, string formatFallbackToPredefinedRoute = null) { return(requestDto.ToUrl(httpMethod, formatFallbackToPredefinedRoute)); }
public virtual Task <TResponse> PatchAsync <TResponse>(IReturn <TResponse> requestDto) { return(PatchAsync <TResponse>(requestDto.ToUrl(HttpMethods.Patch, Format), requestDto)); }
public virtual HttpWebResponse Head(IReturn requestDto) { return(Send <HttpWebResponse>(HttpMethods.Head, requestDto.ToUrl(HttpMethods.Head), requestDto)); }
public TResponse Patch <TResponse>(IReturn <TResponse> request) { return(GetSyncResponse(SendAsync <TResponse>(HttpMethods.Patch, request.ToUrl(HttpMethods.Patch, Format), request))); }
public virtual TResponse Delete <TResponse>(IReturn <TResponse> requestDto) { return(Delete <TResponse>(requestDto.ToUrl(HttpMethods.Delete, Format))); }
public virtual TResponse Get <TResponse>(IReturn <TResponse> requestDto) { return(Get <TResponse>(requestDto.ToUrl(HttpMethods.Get, Format))); }
public TResponse CustomMethod <TResponse>(string httpVerb, IReturn <TResponse> request) { return(GetSyncResponse(SendAsync <TResponse>(httpVerb, request.ToUrl(httpVerb, Format), request))); }
public virtual TResponse CustomMethod <TResponse>(string httpVerb, IReturn <TResponse> requestDto) { return(CustomMethod <TResponse>(httpVerb, requestDto.ToUrl(httpVerb, Format), requestDto)); }