ServeLink handles requests to redirect to a link
(c web.C, w http.ResponseWriter, r *http.Request)
| 47 | |
| 48 | // ServeLink handles requests to redirect to a link |
| 49 | func ServeLink(c web.C, w http.ResponseWriter, r *http.Request) { |
| 50 | l, ok := links[strings.TrimPrefix(r.URL.Path, "/")] |
| 51 | if !ok { |
| 52 | http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) |
| 53 | return |
| 54 | } |
| 55 | http.Redirect(w, r, l.Target, http.StatusFound) |
| 56 | return |
| 57 | } |
| 58 | |
| 59 | // ListLinks returns a list of the current user's links |
| 60 | func ListLinks(c web.C, w http.ResponseWriter, r *http.Request) { |