mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-13 14:57:53 +02:00
Add Endpoint GET /v2/Manga to request multiple Manga from internalIds #167
This commit is contained in:
@ -24,6 +24,7 @@ public partial class Server : GlobalBase, IDisposable
|
||||
new ("GET", @"/v2/Connector/Types", GetV2ConnectorTypes),
|
||||
new ("GET", @"/v2/Connector/([a-zA-Z]+)/GetManga", GetV2ConnectorConnectorNameGetManga),
|
||||
new ("GET", @"/v2/Mangas", GetV2Mangas),
|
||||
new ("GET", @"/v2/Manga", GetV2Manga),
|
||||
new ("GET", @"/v2/Manga/([-A-Za-z0-9]*={0,3})", GetV2MangaInternalId),
|
||||
new ("DELETE", @"/v2/Manga/([-A-Za-z0-9]*={0,3})", DeleteV2MangaInternalId),
|
||||
new ("GET", @"/v2/Manga/([-A-Za-z0-9]*={0,3})/Cover", GetV2MangaInternalIdCover),
|
||||
|
@ -11,6 +11,22 @@ public partial class Server
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, GetAllCachedManga().Select(m => m.internalId));
|
||||
}
|
||||
|
||||
private ValueTuple<HttpStatusCode, object?> GetV2Manga(GroupCollection groups, Dictionary<string, string> requestParameters)
|
||||
{
|
||||
if(!requestParameters.TryGetValue("mangaIds", out string? mangaIdListStr))
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.BadRequest, "Missing parameter 'mangaIds'.");
|
||||
string[] mangaIdList = mangaIdListStr.Split(',');
|
||||
List<Manga> ret = new();
|
||||
foreach (string mangaId in mangaIdList)
|
||||
{
|
||||
if(!_parent.TryGetPublicationById(mangaId, out Manga? manga) || manga is null)
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotFound, $"Manga with id '{mangaId}' not found.");
|
||||
ret.Add(manga.Value);
|
||||
}
|
||||
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, ret);
|
||||
}
|
||||
|
||||
private ValueTuple<HttpStatusCode, object?> GetV2MangaInternalId(GroupCollection groups, Dictionary<string, string> requestParameters)
|
||||
{
|
||||
if(groups.Count < 1 ||
|
||||
|
Reference in New Issue
Block a user