public JsonPlaceholderController() { // Create client here initially and then move to creating it in Startup and passing through to controller using Dependency Injection IJsonPlaceholderService jsonPlaceholderService = new JsonPlaceholderHttpService("https://jsonplaceholder.typicode.com/"); _jsonPlaceholderClient = new JsonPlaceholderClient(jsonPlaceholderService); // https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-3.1 // Then inject a logger and use to log requests }
public JsonPlaceholderService(IJsonPlaceholderClient jsonPlaceholderClient) { _jsonPlaceholderClient = jsonPlaceholderClient; }
public AlbumsController(IJsonPlaceholderClient service, IMapper mapper) { this.service = service; this.mapper = mapper; }
public RunpathApplicationService(IJsonPlaceholderClient jsonPlaceholderClient) { this.jsonPlaceholderClient = jsonPlaceholderClient; }
public PostsController(IMapper mapper, IJsonPlaceholderClient client) { this.mapper = mapper; this.client = client; }
public JsonPlaceholderController(IJsonPlaceholderClient jpClient) { _jpClient = jpClient ?? throw new ArgumentNullException(nameof(jpClient)); }