Пример #1
0
        public async Task <HttpResponseMessage> LogAsync()
        {
            var httpRequestMessage = new HttpRequestMessage
            {
                Method     = HttpMethod.Post,
                RequestUri = new Uri(_administrationProxyOptions.Log.Resource, UriKind.Relative),
            };

            return(await _durableRestService.ExecuteAsync(_httpClient, httpRequestMessage, _administrationProxyOptions.Log.Retrys, _administrationProxyOptions.Log.TimeoutInSeconds).ConfigureAwait(false));
        }
Пример #2
0
        public async Task <HttpResponse <CreateResponse> > CreateAsync(CreateRequest createRequest, string bearerToken)
        {
            var httpRequestMessage = new HttpRequestMessage
            {
                Method     = HttpMethod.Post,
                RequestUri = new Uri(_coasterProxyOptions.Create.Resource, UriKind.Relative),
                Content    = new StringContent(JsonSerializer.Serialize(createRequest), Encoding.UTF8, "application/json")
            };

            httpRequestMessage.Headers.Add(AUTHORIZATION, bearerToken);

            return(await _durableRestService.ExecuteAsync <CreateResponse>(_httpClient, httpRequestMessage, _coasterProxyOptions.Create.Retrys, _coasterProxyOptions.Create.TimeoutInSeconds).ConfigureAwait(false));
        }
Пример #3
0
        public async Task <HttpResponse <Todo> > GetTodosAsync(GetTodosRequest getTodosRequest)
        {
            var httpRequestMessage = new HttpRequestMessage
            {
                Method     = HttpMethod.Get,
                RequestUri = new Uri($"{_options.GetTodosResource}{getTodosRequest.Items}", UriKind.Relative)
            };

            return(await _durableRestService.ExecuteAsync <Todo>(_httpClient, httpRequestMessage, _options.GetTodosRetrys, _options.GetTodosTimeoutInSeconds).ConfigureAwait(false));
        }
Пример #4
0
        private async Task Request(ICorrelationService correlationService, IGuidService guidService, IDurableRestService durableRestService)
        {
            correlationService.CorrelationId = guidService.NewGuid().ToString();

            using var httpClient = new HttpClient
                  {
                      BaseAddress = new Uri("https://jsonplaceholder.typicode.com/")
                  };

            var httpRequestMessage = new HttpRequestMessage
            {
                Method     = HttpMethod.Get,
                RequestUri = new Uri("todos/1", UriKind.Relative)
            };

            var retrys           = 3;
            var timeoutInSeconds = 30;
            var restResponse     = await durableRestService.ExecuteAsync(httpClient, httpRequestMessage, retrys, timeoutInSeconds).ConfigureAwait(false);
        }