public ShortenerModule(IUrlStorage urlStorage) { storage = urlStorage; Post["/urls"] = HandleCreate; Get["/urls/{shortUrl}"] = HandlerGet; }
public UrlShortenerController(IUrlKeyGenerator generator, IUrlStorage storage) { this.generator = generator; this.storage = storage; }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapGet("/who", async context => { context.toUtf8(); context.Response.Headers.Add("InCamp-Student", Dns.GetHostName().ToString()); await context.Response.WriteAsync(Quote.GetRandomWho()); }); endpoints.MapGet("/how", async context => { context.toUtf8(); context.Response.Headers.Add("InCamp-Student", Dns.GetHostName().ToString()); await context.Response.WriteAsync(Quote.GetRandomHow()); }); endpoints.MapGet("/does", async context => { context.toUtf8(); context.Response.Headers.Add("InCamp-Student", Dns.GetHostName().ToString()); await context.Response.WriteAsync(Quote.GetRandomDoes()); }); endpoints.MapGet("/what", async context => { context.toUtf8(); context.Response.Headers.Add("InCamp-Student", Dns.GetHostName().ToString()); await context.Response.WriteAsync(Quote.GetRandomWhat()); }); endpoints.MapGet("/quote", async context => { context.toUtf8(); context.Response.Headers.Add("InCamp-Student", Dns.GetHostName().ToString()); await context.Response.WriteAsync(Quote.GetQuote()); }); endpoints.MapGet("/incamp18-quote", async context => { Timer timer = new Timer(); timer.Start(); context.toUtf8(); context.Response.Headers.Add("InCamp-Student", Dns.GetHostName().ToString()); IUrlStorage urlStorage = ConfigParams.UrlStorage; string[] urls = ConfigParams.RandomUrl.GetRandomUrls(urlStorage.Get()); WebResponse[] responses = await ConfigParams.RequestType.makeRequest(urls); ResponseInfo[] info = responses.Select(r => r.GetInformation()).ToArray(); timer.End(); await context.Response.WriteAsync(info.BuildResponse() + "<br>" + timer.GetTime()); }); }); }
public RedirectMiddleware(OwinMiddleware next, IUrlStorage <Domain.Entities.PunyUrl> urlStorage) : base(next) { this.urlStorage = urlStorage; }
public UrlController(IUrlStorage <Domain.Entities.PunyUrl> storage, IUrlShortener shortener) { this.storage = storage; this.shortener = shortener; }