sources/src/Monetco.Host/Controllers/SimulatorController.cs
/// <summary>
/// Make a GET request and send other request to chosen URL (from ResponseUrl). 
/// </summary>
/// <param name="id">SS ID</param>
/// <param name="scope">redirect scope</param>
/// <param name="method">Chosen method (e.g. GET or POST)</param>
/// <returns>IActionResult 200 or 400 if responses were not loaded</returns>
Make a GET request and send other request to chosen URL (from ResponseUrl).
Make a GET request and send other request to chosen URL ( from ResponseUrl ) .
[ApiExplorerSettings(GroupName = "EmulatedServices")]
        [HttpGet("{id}/{scope}/request/{method}")]
        public IActionResult RedirectResult([FromRoute]string id, [FromRoute]string scope, [FromRoute]string method)
        {
            var req = _service.AddRequest(id, Request);
            var response = _service.GetResponseByScope(id, scope);
            if (response != null)
            {
                using (var client = new HttpClient())
                {
                    var message = new HttpRequestMessage();
                    message.Method = new HttpMethod(method);
                    message.Content = new StringContent(response.Content);
                    message.Content.Headers.ContentType.MediaType = response.ContentType;
                    message.RequestUri = new Uri(response.Url);
                    var result = client.SendAsync(message).Result.Content.ReadAsStringAsync().Result;
                    return Ok("Done");
                }
            }
            return NotFound("Failed to found response");
        }
[ ApiExplorerSettings ( GroupName = " " ) ] [ HttpGet ( " " ) ] public IActionResult RedirectResult ( [ FromRoute ] string id , [ FromRoute ] string scope , [ FromRoute ] string method ) { var req = _service . AddRequest ( id , Request ) ; var response = _service . GetResponseByScope ( id , scope ) ; if ( response != null ) { using ( var client = new HttpClient ( ) ) { var message = new HttpRequestMessage ( ) ; message . Method = new HttpMethod ( method ) ; message . Content = new StringContent ( response . Content ) ; message . Content . Headers . ContentType . MediaType = response . ContentType ; message . RequestUri = new Uri ( response . Url ) ; var result = client . SendAsync ( message ) . Result . Content . ReadAsStringAsync ( ) . Result ; return Ok ( " " ) ; } } return NotFound ( " " ) ; }
Make a GET request and send other request to chosen URL (from ResponseUrl).
Make a GET request and send other request to chosen URL ( from ResponseUrl ) .
//TODO: need to add a new scope redirect
IActionResult 200 or 400 if responses were not loaded
IActionResult 200 or 400 if responses were not loaded
string
[FromRoute]
id
None
scope
None
method
None