|
|
|
@ -10,6 +10,7 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Page struct {
|
|
|
|
|
Host string
|
|
|
|
|
Title string
|
|
|
|
|
Body string
|
|
|
|
|
}
|
|
|
|
@ -34,7 +35,7 @@ func index(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
fmt.Printf("Token: %s Redirect to: %s \n", string(r.URL.Path[1:]), redirect)
|
|
|
|
|
} else {
|
|
|
|
|
t, _ := template.ParseFiles("template/index.gohtml")
|
|
|
|
|
t.Execute(w, nil)
|
|
|
|
|
t.Execute(w, Page{Title: "Shrt"})
|
|
|
|
|
}
|
|
|
|
|
case "POST":
|
|
|
|
|
var test string
|
|
|
|
@ -42,10 +43,9 @@ func index(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
P := Page{Title: r.FormValue("url"), Body: token}
|
|
|
|
|
P := Page{Title: "Url:", Body: r.Host + "/" + token}
|
|
|
|
|
t, _ := template.ParseFiles("template/index.gohtml")
|
|
|
|
|
t.Execute(w, P)
|
|
|
|
|
fmt.Println("Token by Url:", P)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|