public override void HandleRequest(HttpContextBase context) { if (CanHandle(context)) { try { var installedPackage = _installationRecorder.GetLatestPackage(); if (installedPackage is InstalledPackageNotFound) { context.Response.StatusCode = (int)HttpStatusCode.NoContent; } else { var json = new JavaScriptSerializer().Serialize(new { installedPackage }); JsonResponse(json, HttpStatusCode.OK, context); } } catch (NotFoundException) { context.Response.StatusCode = (int)HttpStatusCode.NotFound; } } else if (Successor != null) { Successor.HandleRequest(context); } }
public override void HandleRequest(HttpContextBase context) { if (CanHandle(context)) { var packageName = context.Request["name"]; if (!string.IsNullOrWhiteSpace(packageName)) { var versionText = UpdatePackageVersionRetriver.GetUpdatePackageVersion(packageName); TextResponse(versionText, HttpStatusCode.OK, context); return; } try { var installedPackage = _installationRecorder.GetLatestPackage(); if (installedPackage is InstalledPackageNotFound) { context.Response.StatusCode = (int)HttpStatusCode.NoContent; } else { var json = Json.Encode(new { installedPackage }); JsonResponse(json, HttpStatusCode.OK, context); } } catch (NotFoundException) { context.Response.StatusCode = (int)HttpStatusCode.NotFound; } } else if (Successor != null) { Successor.HandleRequest(context); } }
private dynamic LatestVersion(dynamic o) { try { var installedPackage = _installationRecorder.GetLatestPackage(); if (installedPackage is InstalledPackageNotFound) { return(new Response { StatusCode = HttpStatusCode.NoContent }); } return(Response.AsJson(installedPackage)); } catch (NotFoundException) { return(new Response { StatusCode = HttpStatusCode.NotFound }); } }