diff --git a/main.go b/main.go
index 9d8f9aa..74a40cb 100644
--- a/main.go
+++ b/main.go
@@ -26,6 +26,59 @@ const (
appVersion = "0.0.1"
)
+const indexPage = `
+
+
+
+ Short: the simple url shortener
+
+
+
+
+
+
+`
+
+const returnPage = `
+
+
+
+ Short: the simple url shortner
+
+
+
+
+
+
+`
+
var domain string
var redisServer string
var listenAddr string
@@ -34,6 +87,7 @@ var path string
var src = rand.NewSource(time.Now().UnixNano())
var pool = newPool()
+func index() string { return indexPage }
func newPool() *redis.Pool {
return &redis.Pool{
// Maximum number of idle connections in the pool.
@@ -131,7 +185,9 @@ func shortner(ctx *web.Context) {
if err != nil {
ctx.Abort(500, "Internal Error")
} else {
- ctx.WriteString("URL shortened at: " + proto + "://" + domain + port + path + suffix + "\n")
+ shortend := proto + "://" + domain + port + path + suffix
+ output := fmt.Sprintf(returnPage, shortend, shortend)
+ ctx.WriteString(output)
}
}
}
@@ -171,6 +227,7 @@ func main() {
path = path + "/"
}
+ web.Get("/", index)
web.Post("/", shortner)
web.Get("/(.*)", redirect)
log.Printf("Domain: %s, Redis: %s\n", domain, redisServer)