-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial support for proxied search query #9
- Loading branch information
Showing
11 changed files
with
120 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Linq; | ||
using System.Threading; | ||
using Carter; | ||
using Carter.ModelBinding; | ||
using Carter.Request; | ||
using Carter.Response; | ||
using LiGet.Cache; | ||
using LiGet.Configuration; | ||
using LiGet.WebModels; | ||
using NuGet.Protocol.Core.Types; | ||
|
||
namespace LiGet.CarterModules | ||
{ | ||
public class CacheSearchModule : CarterModule | ||
{ | ||
const string prefix = "api/cache"; | ||
|
||
public CacheSearchModule(ICacheService cacheService) { | ||
this.Get("/api/cache/v3/search", async (req, res, routeData) => { | ||
var query = req.Query.As<string>("q"); | ||
int? skip = req.Query.As<int?>("skip"); | ||
int? take = req.Query.As<int?>("take"); | ||
bool? prerelease = req.Query.As<bool?>("prerelease"); | ||
string semVerLevel = req.Query.As<string>("semVerLevel"); | ||
query = query ?? string.Empty; | ||
var results = await cacheService.SearchAsync(query, new SearchFilter(prerelease ?? false), skip ?? 0, take ?? 0, CancellationToken.None); | ||
await res.AsJson(new | ||
{ | ||
TotalHits = results.Count(), | ||
Data = results.Select(r => new SearchResultModel(r, r.GetVersionsAsync().Result, req, prefix)) | ||
}); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters