Commit 241fdbc4 authored by santiaago's avatar santiaago
Browse files

add cache to hexa16 route.

parent 1623abbf
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import (
	"net/http"

	"github.com/taironas/route"
	"github.com/taironas/tinygraphs/cache"
	"github.com/taironas/tinygraphs/draw/isogrids"
	"github.com/taironas/tinygraphs/extract"
	"github.com/taironas/tinygraphs/write"
@@ -29,6 +30,11 @@ func Hexa16(w http.ResponseWriter, r *http.Request) {
	lines := extract.Hexalines(r)
	colors := extract.Colors(r)

	if Cache.IsCached(&w, r, key, colors, size) {
		w.WriteHeader(http.StatusNotModified)
		return
	}

	write.ImageSVG(w)
	isogrids.Hexa16(w, key, colors, size, lines)
}