public void SubmitLink(IManosContext ctx, Shorty app, string link) { string id = GenerateHash (link, 5); Cache [id] = new LinkData (link); ctx.Response.Redirect ("/r/" + id + "~"); }
public void SubmitLink(IManosContext ctx, Shorty app, string link, bool show_info) { string id = GenerateHash (link, 5); if (show_info) ctx.Response.SetCookie ("show_info", "true"); Cache [id] = new LinkData (link); ctx.Response.Redirect ("/r/" + id + "~"); }
public void SubmitLink(IManosContext ctx, Shorty app, string link, bool show_info) { string id = GenerateHash(link, 5); if (show_info) { ctx.Response.SetCookie("show_info", "true"); } Cache.Set(id, new LinkData(link), (name, item) => { ctx.Response.Redirect("/r/" + id + "~"); }); }
public void LinkInfo(IManosContext ctx, Shorty app, string id) { LinkData info = Cache [id] as LinkData; if (info == null) { ctx.Response.StatusCode = 404; return; } ctx.Response.WriteLine (@"<html> <head><title>Welcome to Shorty</title></head> <body> {0} was clicked {1} times. </body>", info.Link, info.Clicks); }
public void Redirector(IManosContext ctx, Shorty app, string id) { LinkData info = Cache [id] as LinkData; if (info == null) { ctx.Response.StatusCode = 404; return; } // // Because multiple http transactions could be occuring at the // same time, we need to make sure this shared data is incremented // properly // Interlocked.Increment (ref info.Clicks); ctx.Response.Redirect (info.Link); }
public void LinkInfo(IManosContext ctx, Shorty app, string id) { Cache.Get (id, (name, item) => { LinkData info = item as LinkData; if (info == null) { ctx.Response.StatusCode = 404; ctx.Response.End (); return; } ctx.Response.End (@"<html> <head><title>Welcome to Shorty</title></head> <body> <a href='{0}'>{0}</a> was clicked {1} times. </body> </html>", info.Link, info.Clicks); }); }
public void Redirector(IManosContext ctx, Shorty app, string id) { if (ctx.Request.Cookies.Get("show_info") != null) { LinkInfo(ctx, app, id); return; } Cache.Get(id, (name, item) => { LinkData info = item as LinkData; if (info == null) { ctx.Response.StatusCode = 404; return; } ++info.Clicks; ctx.Response.Redirect(info.Link); }); }
public void LinkInfo(IManosContext ctx, Shorty app, string id) { Cache.Get(id, (name, item) => { LinkData info = item as LinkData; if (info == null) { ctx.Response.StatusCode = 404; ctx.Response.End(); return; } ctx.Response.End(@"<html> <head><title>Welcome to Shorty</title></head> <body> <a href='{0}'>{0}</a> was clicked {1} times. </body> </html>" , info.Link, info.Clicks); }); }
public void Redirector(IManosContext ctx, Shorty app, string id) { if (ctx.Request.Cookies.Get ("show_info") != null) { LinkInfo (ctx, app, id); return; } Cache.Get (id, (name, item) => { LinkData info = item as LinkData; if (info == null) { ctx.Response.StatusCode = 404; return; } ++info.Clicks; ctx.Response.Redirect (info.Link); }); }