If you are looking for the ASP.NET version please head to ApiTracker project.
| NuGet downloads (ApiTracker) | NuGet downloads (ApiTracker.AspNetCore) |
|---|---|
PM> Install-Package ApiTracker.AspNetCore
"ApiTrackerSetting": {
"ElasticConnection": "", // elastic地址,例如 http://localhost:9200
"DocumentName": "", // 文档名称,默认apitracker
"TimeOut": 500 // 写入超时时间,单位毫秒,默认500
}// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
// ...其他
services.Configure<ApiTrackerSetting>(Configuration.GetSection("ApiTrackerSetting"));
services.AddScoped<ApiTracker.ApiTracker>();
} [Route("values")]
[ServiceFilter(typeof(ApiTracker.ApiTracker),IsReusable = true)]
public class ValuesController : Controller
{
// GET api/values
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// POST api/values
[HttpPost]
[ApiTracker.ApiTrackerOptions(EnableClientIp =false)]
public void Post([FromBody]JObject value)
{
}
}