Files
onepeek/src/OnePeek.WebConsole/Modules/ApiModule.cs
T

36 lines
1.1 KiB
C#
Raw Normal View History

using Nancy;
using OnePeek.Api;
using OnePeek.Entities;
using System.IO;
2015-04-03 22:40:12 +02:00
namespace OnePeek.WebConsole.Modules
{
2015-04-01 02:21:22 +02:00
public class ApiModule : NancyModule
{
2015-04-01 02:21:22 +02:00
public ApiModule() : base("api/")
{
AppRatingEndpoint ratingEndpoint = new AppRatingEndpoint();
AppMetadataEndpoint metaEndpoint = new AppMetadataEndpoint();
2015-04-03 22:40:12 +02:00
Get["/meta/{id}", true] = async (ctx, token) =>
{
AppMetadata meta = await metaEndpoint.GetMetadata(ctx.id, StoreType.WindowsPhone8, StoreCultureType.EN_US);
return Response.AsJson(meta);
};
2015-04-03 22:40:12 +02:00
Get["/reviews/{id}", true] = async (ctx, token) =>
{
AppReviews reviews = await ratingEndpoint.GetReviews(ctx.id, StoreType.WindowsPhone8, StoreCultureType.EN_US, StoreReviewSorting.Latest);
return Response.AsJson(reviews);
};
2015-04-03 22:40:12 +02:00
Get["/image/{id}.jpg", true] = async (ctx, token) =>
{
Stream imageStream = await metaEndpoint.GetImageAsStream(ctx.id, StoreImageType.None);
return Response.FromStream(imageStream, "image/jpeg");
};
}
}
}