spring-bootspring-securityhttp-status-code-503maintenance-mode

Spring boot block requests for maintenance and return 503 error on each requests


how I can do in order to return 503 server error response code when my api is under maintenance?


Solution

  • Usually microservices tend to have a API gateway where you implement solutions such parsing some header token and inserting new headers , rate limiting , checks like if a user is administrator or not etc

    https://learn.microsoft.com/en-us/dotnet/architecture/microservices/architect-microservice-container-applications/direct-client-to-microservice-communication-versus-the-api-gateway-pattern

    You can use https://spring.io/projects/spring-cloud-gateway which is used build API gateway based on spring stack

    I believe you can use this to temporarily shutdown certain routes and also configure different errors