From f31c946b0ded52959077c6d06d461b408d8059ab Mon Sep 17 00:00:00 2001 From: Tatsuro Shibamura Date: Thu, 30 Jul 2026 20:07:51 +0900 Subject: [PATCH] Refactor response handling in certificate operations to use relative URL paths --- docs/reference/api.md | 2 +- src/Acmebot.App/Functions/Http/AddCertificate.cs | 2 +- src/Acmebot.App/Functions/Http/GetOperation.cs | 2 +- src/Acmebot.App/Functions/Http/RenewCertificate.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/reference/api.md b/docs/reference/api.md index 442e46be..7669531d 100644 --- a/docs/reference/api.md +++ b/docs/reference/api.md @@ -35,7 +35,7 @@ When app role enforcement is enabled, issue and renew operations require `Acmebo ## Operation Lifecycle -`POST /api/certificates` and `POST /api/certificates/{certificateName}/renew` return `202 Accepted` with a `Location` header. Poll that URL until it returns: +`POST /api/certificates` and `POST /api/certificates/{certificateName}/renew` return `202 Accepted` with a `Location` header. The header holds a path relative to the request, so resolve it against the endpoint you called. Poll that URL until it returns: | Status | Meaning | | --- | --- | diff --git a/src/Acmebot.App/Functions/Http/AddCertificate.cs b/src/Acmebot.App/Functions/Http/AddCertificate.cs index 93e89264..5c8ac2cf 100644 --- a/src/Acmebot.App/Functions/Http/AddCertificate.cs +++ b/src/Acmebot.App/Functions/Http/AddCertificate.cs @@ -42,7 +42,7 @@ public async Task HttpStart( LogOrchestrationStarted(logger, certificatePolicyItem.CertificateName, instanceId); - return AcceptedAtFunction($"{nameof(GetOperation)}_{nameof(GetOperation.HttpStart)}", new { instanceId }, null); + return Accepted(Url.RouteUrl($"{nameof(GetOperation)}_{nameof(GetOperation.HttpStart)}", new { instanceId }), null); } [LoggerMessage(LogLevel.Information, "Certificate issuance orchestration started. CertificateName: {CertificateName}. InstanceId: {InstanceId}")] diff --git a/src/Acmebot.App/Functions/Http/GetOperation.cs b/src/Acmebot.App/Functions/Http/GetOperation.cs index 33bd37ba..d8582d88 100644 --- a/src/Acmebot.App/Functions/Http/GetOperation.cs +++ b/src/Acmebot.App/Functions/Http/GetOperation.cs @@ -33,7 +33,7 @@ public async Task HttpStart( return metadata.RuntimeStatus switch { OrchestrationRuntimeStatus.Failed => Problem(metadata.FailureDetails?.ErrorMessage, type: metadata.FailureDetails?.ErrorType), - OrchestrationRuntimeStatus.Running or OrchestrationRuntimeStatus.Pending => AcceptedAtFunction($"{nameof(GetOperation)}_{nameof(HttpStart)}", new { instanceId }, null), + OrchestrationRuntimeStatus.Running or OrchestrationRuntimeStatus.Pending => Accepted(Url.RouteUrl($"{nameof(GetOperation)}_{nameof(HttpStart)}", new { instanceId }), null), _ => Ok() }; } diff --git a/src/Acmebot.App/Functions/Http/RenewCertificate.cs b/src/Acmebot.App/Functions/Http/RenewCertificate.cs index 03acc8fc..777d58dd 100644 --- a/src/Acmebot.App/Functions/Http/RenewCertificate.cs +++ b/src/Acmebot.App/Functions/Http/RenewCertificate.cs @@ -43,7 +43,7 @@ public async Task HttpStart( LogOrchestrationStarted(logger, certificateName, instanceId); - return AcceptedAtFunction($"{nameof(GetOperation)}_{nameof(GetOperation.HttpStart)}", new { instanceId }, null); + return Accepted(Url.RouteUrl($"{nameof(GetOperation)}_{nameof(GetOperation.HttpStart)}", new { instanceId }), null); } [LoggerMessage(LogLevel.Information, "Certificate renewal orchestration started. CertificateName: {CertificateName}. InstanceId: {InstanceId}")]