Skip to content

abcba/ApiTracker.AspNetCore

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ApiTracker.AspNetCore  Build status NuGet


If you are looking for the ASP.NET version please head to ApiTracker project.


NuGet downloads (ApiTracker) NuGet downloads (ApiTracker.AspNetCore)
NuGet downloads ApiTracker NuGet downloads ApiTracker.AspNetCore

PM> Install-Package ApiTracker.AspNetCore

appsettings.json 配置

 "ApiTrackerSetting": {
    "ElasticConnection": "",
    "DocumentName": "",
    "TimeOut": 500
  }
ElasticConnection: elastic地址,例如 http://localhost:9200
DocumentName:文档名称,默认apitracker
TimeOut:写入超时时间,单位毫秒,默认500

Startup.cs 配置

// 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>();
}

API Controller 配置

    [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)
        {

        }
    }

About

WebApi Tracker with ElasticSearch tech

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%