using ColorService.Models; using ColorService.Utility; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; namespace ColorService.Controllers { [Route("[controller]")] [ApiController] public class ColorController : ControllerBase { public IOptionsSnapshot Settings { get; } public ColorController(IOptionsSnapshot settings) { this.Settings = settings; } // GET: api/ [HttpGet] public string Get() => this.Settings.Value.Color.OrDefaultIfBlank("Green"); // GET api//Red [HttpGet("{color}")] public string Get(string color) => color.OrDefaultIfBlank(this.Get()); } }