feat(ProxyController): Optionaler Körper als Dictionary<string, object> hinzugefügt
This commit is contained in:
parent
54fce2990b
commit
6dc8bd233b
@ -6,7 +6,7 @@ namespace DigitalData.Swagger.MockAPI.Controllers
|
|||||||
public class MockController : ControllerBase
|
public class MockController : ControllerBase
|
||||||
{
|
{
|
||||||
[HttpPost("{servicetierName}/ODataV4/{webserviceName}_CreateInvoice")]
|
[HttpPost("{servicetierName}/ODataV4/{webserviceName}_CreateInvoice")]
|
||||||
public IActionResult CreateInvoice([FromRoute] string servicetierName, [FromRoute] string webserviceName, [FromQuery] string company)
|
public IActionResult CreateInvoice([FromRoute] string servicetierName, [FromRoute] string webserviceName, [FromQuery] string company, Dictionary<string, object>? body)
|
||||||
{
|
{
|
||||||
return Created($"{servicetierName}/ODataV4/{webserviceName}?id={1}", new { Id = 1, Foo = 1});
|
return Created($"{servicetierName}/ODataV4/{webserviceName}?id={1}", new { Id = 1, Foo = 1});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ public class ProxyController(IOptions<OriginServerParams> originServerParamsOpti
|
|||||||
private readonly OriginServerParams _origin = originServerParamsOptions.Value;
|
private readonly OriginServerParams _origin = originServerParamsOptions.Value;
|
||||||
|
|
||||||
[HttpPost("{servicetierName}/ODataV4/{webserviceName}_CreateInvoice")]
|
[HttpPost("{servicetierName}/ODataV4/{webserviceName}_CreateInvoice")]
|
||||||
public async Task<IActionResult> Redir([FromRoute] string servicetierName, [FromRoute] string webserviceName, [FromQuery] string company)
|
public async Task<IActionResult> Redir([FromRoute] string servicetierName, [FromRoute] string webserviceName, [FromQuery] string company, [FromBody] Dictionary<string, object>? body = null)
|
||||||
{
|
{
|
||||||
var req = _origin.Url
|
var req = _origin.Url
|
||||||
.AppendPathSegment(servicetierName)
|
.AppendPathSegment(servicetierName)
|
||||||
@ -36,7 +36,7 @@ public class ProxyController(IOptions<OriginServerParams> originServerParamsOpti
|
|||||||
req = req.WithCookie(cookie.Key, cookie.Value);
|
req = req.WithCookie(cookie.Key, cookie.Value);
|
||||||
|
|
||||||
//post request
|
//post request
|
||||||
var res = await req.PostAsync();
|
var res = body is null ? await req.PostAsync() : await req.PostJsonAsync(body);
|
||||||
|
|
||||||
// set headers
|
// set headers
|
||||||
foreach (var (Name, Value) in res.Headers)
|
foreach (var (Name, Value) in res.Headers)
|
||||||
@ -46,10 +46,10 @@ public class ProxyController(IOptions<OriginServerParams> originServerParamsOpti
|
|||||||
foreach (var (Name, Value) in res.Cookies.ToKeyValuePairs())
|
foreach (var (Name, Value) in res.Cookies.ToKeyValuePairs())
|
||||||
HttpContext.Response.Cookies.Append(Name, Value.ToString() ?? string.Empty);
|
HttpContext.Response.Cookies.Append(Name, Value.ToString() ?? string.Empty);
|
||||||
|
|
||||||
var body = res.GetJsonAsync<dynamic>();
|
var resBody = res.GetJsonAsync<dynamic>();
|
||||||
|
|
||||||
if (body is not null)
|
if (resBody is not null)
|
||||||
return new JsonResult(body)
|
return new JsonResult(resBody)
|
||||||
{
|
{
|
||||||
StatusCode = res.StatusCode
|
StatusCode = res.StatusCode
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user