refactor(ProxyController): Aktualisiert, um JsonResult zu verwenden, wenn es einen Körper in der Redir-Methode gibt.
This commit is contained in:
parent
1fde6e7e34
commit
7189b39d6b
@ -1,10 +1,7 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DigitalData.Swagger.MockAPI.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class MockController : ControllerBase
|
||||
{
|
||||
|
||||
@ -19,8 +19,7 @@ public class ProxyController(IOptions<OriginServerParams> originServerParamsOpti
|
||||
var res = await origin.Url
|
||||
.AppendPathSegment(servicetierName)
|
||||
.AppendPathSegment("ODataV4")
|
||||
.AppendPathSegment(webserviceName)
|
||||
.AppendPathSegment("_CreateInvoice")
|
||||
.AppendPathSegment(webserviceName + "_CreateInvoice")
|
||||
.SetQueryParams(new { company })
|
||||
//.WithOAuthBearerToken("my_oauth_token")
|
||||
.PostAsync();
|
||||
@ -33,6 +32,13 @@ public class ProxyController(IOptions<OriginServerParams> originServerParamsOpti
|
||||
foreach (var (Name, Value) in res.Cookies.ToKeyValuePairs())
|
||||
HttpContext.Response.Cookies.Append(Name, Value.ToString() ?? string.Empty);
|
||||
|
||||
return StatusCode(res.StatusCode, res);
|
||||
var body = res.GetJsonAsync<dynamic>();
|
||||
|
||||
if (body is not null)
|
||||
return new JsonResult(body)
|
||||
{
|
||||
StatusCode = res.StatusCode
|
||||
};
|
||||
return StatusCode(res.StatusCode);
|
||||
}
|
||||
}
|
||||
@ -5,5 +5,11 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
"OriginServer": {
|
||||
"Url": "https://localhost:7248",
|
||||
"Headers": {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user