diff --git a/Attributes/DevelopmentOnlyAttribute.cs b/Attributes/DevelopmentOnlyAttribute.cs new file mode 100644 index 0000000..2dd98d0 --- /dev/null +++ b/Attributes/DevelopmentOnlyAttribute.cs @@ -0,0 +1,21 @@ +using System; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.DependencyInjection; + +public class DevelopmentOnlyAttribute : Attribute, IResourceFilter +{ + public void OnResourceExecuting(ResourceExecutingContext context) + { + var env = context.HttpContext.RequestServices.GetService(); + if (!env.IsDevelopment()) + { + context.Result = new NotFoundResult(); + } + } + + public void OnResourceExecuted(ResourceExecutedContext context) + { + } +} \ No newline at end of file diff --git a/Controllers/ContactUsController.cs b/Controllers/ContactUsController.cs index 460cc89..4972b53 100644 --- a/Controllers/ContactUsController.cs +++ b/Controllers/ContactUsController.cs @@ -42,6 +42,7 @@ namespace weddingapi.Controllers } // GET /contact/{id} + [DevelopmentOnly] [HttpGet("{id}")] public async Task> GetContactAsync(Guid id) { @@ -56,6 +57,7 @@ namespace weddingapi.Controllers } // Delete /contact/{id} + [DevelopmentOnly] [HttpDelete("{id}")] public async Task DeleteContactAsync(Guid id) { @@ -72,6 +74,7 @@ namespace weddingapi.Controllers } // GET /contacts + [DevelopmentOnly] [HttpGet] public async Task> GetContactsAsync() { diff --git a/Controllers/FamilyController.cs b/Controllers/FamilyController.cs index 9adc94a..98b9273 100644 --- a/Controllers/FamilyController.cs +++ b/Controllers/FamilyController.cs @@ -33,6 +33,7 @@ namespace weddingapi.Controllers } // GET /family + [DevelopmentOnly] [HttpGet] public async Task> GetFamiliesAsync() { @@ -42,6 +43,7 @@ namespace weddingapi.Controllers } // GET /family/{id} + [DevelopmentOnly] [HttpGet("{id}")] public async Task> GetFamilyAsync(Guid id) { @@ -80,6 +82,7 @@ namespace weddingapi.Controllers } // PUT /family/{id} + [DevelopmentOnly] [HttpPut("{id}")] public async Task UpdateFamilyAsync(Guid id, UpdateFamilyDto familyDto) { @@ -108,6 +111,7 @@ namespace weddingapi.Controllers } // Delete /family/{id} + [DevelopmentOnly] [HttpDelete("{id}")] public async Task DeleteFamilyAsync(Guid id) { diff --git a/README.md b/README.md index 3d964af..0efd5ed 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ docker image tag weddingapi:v2 registry.git.rismer.de/rismer/weddingapi:latest ## Push +docker login registry.git.rismer.de + docker push registry.git.rismer.de/rismer/weddingapi:v2