|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using isnd.Attributes;
|
|
|
|
|
using isnd.Entities;
|
|
|
|
|
using isn.abst;
|
|
|
|
|
|
|
|
|
|
namespace isnd.Controllers
|
|
|
|
|
{
|
|
|
|
|
// TODO /search GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}&packageType={PACKAGETYPE}
|
|
|
|
|
|
|
|
|
|
public partial class PackagesController
|
|
|
|
|
{
|
|
|
|
|
// Web get the paquet
|
|
|
|
|
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Nuget + "/{id}/{lower}/{idf}-{lowerf}."
|
|
|
|
|
+ Constants.PacketFileExtension)]
|
|
|
|
|
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Content + "/{id}/{lower}/{idf}-{lowerf}."
|
|
|
|
|
+ Constants.PacketFileExtension)]
|
|
|
|
|
public IActionResult GetPackage(
|
|
|
|
|
[FromRoute][SafeName][Required] string id,
|
|
|
|
|
[FromRoute][SafeName][Required] string lower,
|
|
|
|
|
[FromRoute] string idf, [FromRoute] string lowerf)
|
|
|
|
|
{
|
|
|
|
|
var pkgpath = Path.Combine(isndSettings.PackagesRootDir,
|
|
|
|
|
id, lower, $"{id}-{lower}." + Constants.PacketFileExtension
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
FileInfo pkgfi = new FileInfo(pkgpath);
|
|
|
|
|
|
|
|
|
|
if (!pkgfi.Exists)
|
|
|
|
|
{
|
|
|
|
|
return BadRequest("!pkgfi.Exists");
|
|
|
|
|
}
|
|
|
|
|
return File(pkgfi.OpenRead(), "application/zip; charset=binary");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Web get spec
|
|
|
|
|
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Nuspec + "/{id}/{lower}/{idf}-{lowerf}."
|
|
|
|
|
+ Constants.SpecFileExtension)]
|
|
|
|
|
public IActionResult GetNuspec(
|
|
|
|
|
[FromRoute][SafeName][Required] string id,
|
|
|
|
|
[FromRoute][SafeName][Required] string lower,
|
|
|
|
|
[FromRoute][SafeName][Required] string idf,
|
|
|
|
|
[FromRoute][SafeName][Required] string lowerf)
|
|
|
|
|
{
|
|
|
|
|
var pkgpath = Path.Combine(isndSettings.PackagesRootDir,
|
|
|
|
|
id, lower, $"{id}." + Constants.SpecFileExtension);
|
|
|
|
|
|
|
|
|
|
FileInfo pkgfi = new FileInfo(pkgpath);
|
|
|
|
|
if (!pkgfi.Exists)
|
|
|
|
|
{
|
|
|
|
|
return BadRequest("!pkgfi.Exists");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return File(pkgfi.OpenRead(), "text/xml; charset=utf-8");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|