This commit is contained in:
Paul Schneider 2022-12-17 01:29:22 +00:00
commit 282b0277ae
10 changed files with 51 additions and 34 deletions

View file

@ -44,13 +44,29 @@ namespace isnd.Controllers
return Ok(leaf.First());
}
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{version}/{lower}/index.json")]
public IActionResult CatalogLeaf(string id, string pversion, string lower)
/// <summary>
/// Catalog Leaf,
/// Get info about given package id, and optional lower part .
/// </summary>
/// <param name="id">Given Package Id</param>
/// <param name="lower">lower part, a semantic version for the package,
/// and eventually followed by the "package type"</param>
/// <returns>Info about concerned packages, in order to be able and download them</returns>
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{lower?}/index.json")]
public IActionResult CatalogLeaf(string id, string lower = null)
{
Data.PackageVersion[] pkgvs = null;
if (lower == "{lower}") lower = null;
bool askForindex = lower == null;
var pkgvs = this.packageManager.GetCatalogLeaf(id, pversion, lower).ToArray();
if (lower != null && lower.IndexOf('/') > 0 )
{
string version = lower.Substring(lower.IndexOf('/'));
pkgvs = this.packageManager.GetCatalogLeaf(id, version, lower).ToArray();
}
else {
pkgvs = this.packageManager.GetCatalogLeaf(id, null, lower).ToArray();
}
if (pkgvs.Count() == 0) return NotFound();
List<string> types = pkgvs.Select(
v => v.Type ?? "Dependency"