mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
add response caching to api
This commit is contained in:
parent
511166e6de
commit
7d2700514e
5 changed files with 38 additions and 3 deletions
|
|
@ -12,8 +12,10 @@
|
|||
"FilterListLanguages": null,
|
||||
"FilterListRules": null,
|
||||
"FilterListSoftware": null,
|
||||
"LicenseId": null,
|
||||
"MaintainerId": null,
|
||||
"Name": "My Sample Advertisement Filter List",
|
||||
"SubmissionUrl": null,
|
||||
"ViewUrl": "https://mysample.list/list.txt",
|
||||
"Id": 0,
|
||||
"CreatedDateUtc": "0001-01-01T00:00:00",
|
||||
|
|
@ -30,8 +32,10 @@
|
|||
"FilterListLanguages": null,
|
||||
"FilterListRules": null,
|
||||
"FilterListSoftware": null,
|
||||
"LicenseId": null,
|
||||
"MaintainerId": null,
|
||||
"Name": "My Sample Malware Filter List",
|
||||
"SubmissionUrl": null,
|
||||
"ViewUrl": "https://mysample.list/list.txt",
|
||||
"Id": 0,
|
||||
"CreatedDateUtc": "0001-01-01T00:00:00",
|
||||
|
|
|
|||
|
|
@ -75,6 +75,12 @@
|
|||
"$ref": "#/definitions/FilterListSoftware"
|
||||
}
|
||||
},
|
||||
"LicenseId": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"MaintainerId": {
|
||||
"type": [
|
||||
"integer",
|
||||
|
|
@ -87,6 +93,12 @@
|
|||
"null"
|
||||
]
|
||||
},
|
||||
"SubmissionUrl": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"ViewUrl": {
|
||||
"type": [
|
||||
"string",
|
||||
|
|
@ -116,8 +128,10 @@
|
|||
"FilterListLanguages",
|
||||
"FilterListRules",
|
||||
"FilterListSoftware",
|
||||
"LicenseId",
|
||||
"MaintainerId",
|
||||
"Name",
|
||||
"SubmissionUrl",
|
||||
"ViewUrl",
|
||||
"Id",
|
||||
"CreatedDateUtc",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.IO;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
|
|
@ -9,12 +10,25 @@ public static class ConfigureServicesCollection
|
|||
{
|
||||
public static void AddFilterListsApi(this IServiceCollection services)
|
||||
{
|
||||
services.AddMvc();
|
||||
services.AddMvcCustom();
|
||||
services.AddApiVersioning();
|
||||
services.AddSwagger();
|
||||
services.AddResponseCaching();
|
||||
services.AddSwaggerGenCustom();
|
||||
}
|
||||
|
||||
private static void AddSwagger(this IServiceCollection services)
|
||||
private static void AddMvcCustom(this IServiceCollection services)
|
||||
{
|
||||
services.AddMvc(options =>
|
||||
{
|
||||
options.CacheProfiles.Add("Long-Lived",
|
||||
new CacheProfile
|
||||
{
|
||||
Duration = 86400
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private static void AddSwaggerGenCustom(this IServiceCollection services)
|
||||
{
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ public void Configure(IApplicationBuilder app)
|
|||
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
|
||||
});
|
||||
|
||||
app.UseResponseCaching();
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public ListsController(IFilterListService filterListService)
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
[ResponseCache(CacheProfileName = "Long-Lived")]
|
||||
public IActionResult Get()
|
||||
{
|
||||
return Json(filterListService.GetAllSummaries());
|
||||
|
|
|
|||
Loading…
Reference in a new issue