public static async Task Stats(IOwinContext context, NuGetSearcherManager searcherManager, ResponseWriter responseWriter) { await responseWriter.WriteResponseAsync( context, HttpStatusCode.OK, jsonWriter => ServiceInfoImpl.Stats(jsonWriter, searcherManager)); }
public async Task Invoke(IOwinContext context) { switch (context.Request.Path.Value) { case "/": await context.Response.WriteAsync("OK"); context.Response.StatusCode = (int)HttpStatusCode.OK; break; case "/find": await ServiceHelpers.WriteResponse(context, HttpStatusCode.OK, ServiceImpl.Find(context, _searcherManager)); break; case "/query": await ServiceHelpers.WriteResponse(context, HttpStatusCode.OK, ServiceImpl.Query(context, _searcherManager)); break; case "/autocomplete": await ServiceHelpers.WriteResponse(context, HttpStatusCode.OK, ServiceImpl.AutoComplete(context, _searcherManager)); break; case "/targetframeworks": await ServiceInfoImpl.TargetFrameworks(context, _searcherManager); break; case "/segments": await ServiceInfoImpl.Segments(context, _searcherManager); break; case "/stats": await ServiceInfoImpl.Stats(context, _searcherManager); break; default: await context.Response.WriteAsync("unrecognized"); context.Response.StatusCode = (int)HttpStatusCode.NotFound; break; } }
public async Task Invoke(IOwinContext context) { string error = null; try { if (_searcherManager == null) { // first hit should try to set the searcher manager if not set yet TrySetSearcherManager(); if (_searcherManager == null) { // something is wrong... await context.Response.WriteAsync("no index loaded"); context.Response.StatusCode = (int)HttpStatusCode.ServiceUnavailable; return; } } switch (context.Request.Path.Value) { case "/": await context.Response.WriteAsync("READY."); context.Response.StatusCode = (int)HttpStatusCode.OK; break; case "/query": await SecureQueryImpl.Query(context, _searcherManager, ServiceHelpers.GetTenant(), ServiceHelpers.GetNameIdentifier()); break; case "/owner": await SecureQueryImpl.QueryByOwner(context, _searcherManager, ServiceHelpers.GetTenant(), ServiceHelpers.GetNameIdentifier()); break; case "/find": await SecureFindImpl.Find(context, _searcherManager, ServiceHelpers.GetTenant()); break; case "/segments": await ServiceInfoImpl.Segments(context, _searcherManager); break; case "/stats": await ServiceInfoImpl.Stats(context, _searcherManager); break; default: string storagePrimary = _configurationService.Get("Storage.Primary"); MetadataImpl.Access(context, string.Empty, _searcherManager, storagePrimary, 30); break; } } catch (Exception e) { Trace.TraceError("Invoke Exception: {0} {1}", e.GetType().Name, e.Message); error = e.Message; } if (error != null) { await Utils.WriteErrorResponse(context, error, HttpStatusCode.InternalServerError); } }