-
-
Save jrob5756/73159c18d871df0aa4ee45726b194b43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Mvc; | |
using System; | |
namespace JrTech.AspNetCore.Web.Controllers | |
{ | |
[Route("api/[controller]")] | |
public class ValuesController : Controller | |
{ | |
private readonly Func<IRandomNumberGenerator> _numberGeneratorFactory; | |
public ValuesController(Func<IRandomNumberGenerator> numberGeneratorFactory) | |
{ | |
_numberGeneratorFactory = numberGeneratorFactory; | |
} | |
// GET api/values | |
[HttpGet] | |
public string Get() | |
{ | |
var generator = _numberGeneratorFactory(); | |
return $"randomNumber - {generator.Get()}" ; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment