Loading app-backend/main.go +2 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import ( "github.com/taironas/tinygraphs/controllers/isogrids" "github.com/taironas/tinygraphs/controllers/spaceinvaders" "github.com/taironas/tinygraphs/controllers/squares" "github.com/taironas/tinygraphs/controllers/themes" ) var root = flag.String("root", "app", "file system path") Loading @@ -33,6 +34,7 @@ func main() { r.HandleFunc("/isogrids/:key", isogrids.Isogrids) r.HandleFunc("/spaceinvaders/:key", spaceinvaders.SpaceInvaders) r.HandleFunc("/themes/:theme", themes.Theme) r.HandleFunc("/labs/checkerboard", checkerboard.Checkerboard) r.HandleFunc("/labs/squares/random", squares.Random) r.HandleFunc("/labs/isogrids/hexa", isogrids.Hexa) Loading controllers/themes/themes.go 0 → 100644 +26 −0 Original line number Diff line number Diff line package themes import ( "log" "net/http" "github.com/taironas/route" "github.com/taironas/tinygraphs/colors" ) // Theme handler builds an image with the colors of a theme // the theme is defined by keyword :theme // url: "/themes/:theme" func Theme(w http.ResponseWriter, r *http.Request) { var err error var theme string if theme, _ = route.Context.Get(r, "theme"); err != nil { theme = "base" } colorMap := colors.MapOfColorThemes() if val, ok := colorMap[theme]; ok { log.Println(val) } } Loading
app-backend/main.go +2 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import ( "github.com/taironas/tinygraphs/controllers/isogrids" "github.com/taironas/tinygraphs/controllers/spaceinvaders" "github.com/taironas/tinygraphs/controllers/squares" "github.com/taironas/tinygraphs/controllers/themes" ) var root = flag.String("root", "app", "file system path") Loading @@ -33,6 +34,7 @@ func main() { r.HandleFunc("/isogrids/:key", isogrids.Isogrids) r.HandleFunc("/spaceinvaders/:key", spaceinvaders.SpaceInvaders) r.HandleFunc("/themes/:theme", themes.Theme) r.HandleFunc("/labs/checkerboard", checkerboard.Checkerboard) r.HandleFunc("/labs/squares/random", squares.Random) r.HandleFunc("/labs/isogrids/hexa", isogrids.Hexa) Loading
controllers/themes/themes.go 0 → 100644 +26 −0 Original line number Diff line number Diff line package themes import ( "log" "net/http" "github.com/taironas/route" "github.com/taironas/tinygraphs/colors" ) // Theme handler builds an image with the colors of a theme // the theme is defined by keyword :theme // url: "/themes/:theme" func Theme(w http.ResponseWriter, r *http.Request) { var err error var theme string if theme, _ = route.Context.Get(r, "theme"); err != nil { theme = "base" } colorMap := colors.MapOfColorThemes() if val, ok := colorMap[theme]; ok { log.Println(val) } }