예제 #1
0
 public HttpResponseMessage Post([FromBody] String url)
 {
     using (UrlManager urlManager = new UrlManager())
     {
         return Request.CreateResponse(HttpStatusCode.OK, urlManager.AddShortUrl(url));
     }
 }
예제 #2
0
 public HttpResponseMessage Get(string key)
 {
     using (UrlManager urlManager = new UrlManager()) {
         var response = Request.CreateResponse(HttpStatusCode.Moved);
         String urlString = urlManager.GetUrl(key);
         if (!String.IsNullOrWhiteSpace(urlString))
         {
             response.Headers.Location = new Uri(urlString);
             return response;
         }
     }
     return null;
 }