Skip to content

Commit

Permalink
Add index paramenter in the URL path
Browse files Browse the repository at this point in the history
  • Loading branch information
zieckey committed Mar 16, 2017
1 parent 2876895 commit 63f3500
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
//"fmt"
"net/http"
"text/template"
"strconv"
"log"
)

var (
Expand All @@ -13,14 +15,23 @@ var (
)

func handler(w http.ResponseWriter, r *http.Request) {
values := r.URL.Query()
i := values.Get("index")
if len(i) > 0 {
Index, _ = strconv.Atoi(i)
} else {
Index++
}

Index = Index % len(ChartFiles)

log.Printf("Index=%v rendering %v", Index, ChartFiles[Index])
tt, err := Parse(ChartFiles[Index])
if err != nil {
w.Write([]byte(err.Error()))
return
}

Index++
Index = Index % len(ChartFiles)

if t, err := template.New("foo").Parse(tt.tmpl); err != nil {
w.Write([]byte(err.Error()))
Expand Down

0 comments on commit 63f3500

Please sign in to comment.