CreateLink handles requests to create links
(c web.C, w http.ResponseWriter, r *http.Request)
| 33 | |
| 34 | // CreateLink handles requests to create links |
| 35 | func CreateLink(c web.C, w http.ResponseWriter, r *http.Request) { |
| 36 | account := r.Header.Get("X-Remote-User") |
| 37 | l := Link{ |
| 38 | ShortLink: uniuri.New(), |
| 39 | Target: r.FormValue("t"), |
| 40 | Owner: account, |
| 41 | } |
| 42 | links[l.ShortLink] = l |
| 43 | |
| 44 | fmt.Fprintf(w, "%s\n", l.ShortLink) |
| 45 | return |
| 46 | } |
| 47 | |
| 48 | // ServeLink handles requests to redirect to a link |
| 49 | func ServeLink(c web.C, w http.ResponseWriter, r *http.Request) { |