ServeLink handles requests to redirect to a link
(w http.ResponseWriter, r *http.Request)
| 119 | |
| 120 | // ServeLink handles requests to redirect to a link |
| 121 | func ServeLink(w http.ResponseWriter, r *http.Request) { |
| 122 | links.mu.Lock() |
| 123 | l, ok := links.links[r.PathValue("link")] |
| 124 | links.mu.Unlock() |
| 125 | if !ok { |
| 126 | http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) |
| 127 | return |
| 128 | } |
| 129 | http.Redirect(w, r, l.Target, http.StatusFound) |
| 130 | } |
| 131 | |
| 132 | // ListLinks returns a list of the current user's links |
| 133 | func ListLinks(w http.ResponseWriter, r *http.Request) { |