diff --git a/CHANGELOG.md b/CHANGELOG.md
index e84280e..766141f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
+## 2019-03-18 - 0.0.3
+
+### Added
+
+- Add some html templates
+
## 2019-03-18 - 0.0.2
### Added
diff --git a/Dockerfile b/Dockerfile
index 5187b2c..6c8f17a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,8 +1,8 @@
-FROM golang:1.12.1 as builder
+FROM golang:1.12.4 as builder
ENV CGO_ENABLED=0
-ADD . /go/src/short
+ADD main.go /go/src/short/
WORKDIR /go/src/short
diff --git a/main.go b/main.go
index 9d8f9aa..4b30b37 100644
--- a/main.go
+++ b/main.go
@@ -23,9 +23,62 @@ const (
letterIdxMax = 63 / letterIdxBits // # of letter indices fitting in 63 bits
)
const (
- appVersion = "0.0.1"
+ appVersion = "0.0.3"
)
+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)