Skip to content

Instantly share code, notes, and snippets.

View simt2's full-sized avatar
🐔
magic is bad

Simon Tesar simt2

🐔
magic is bad
View GitHub Profile
// LoadBreadcrumb retrieves the top level nodes used to display the navigation
func LoadBreadcrumb() []gjson.Result {
r := MeshGetRequest("demo/navroot/?maxDepth=1&resolveLinks=short")
defer r.Body.Close()
bytes, _ := ioutil.ReadAll(r.Body)
json := gjson.ParseBytes(bytes).Get("root.children").Array()
return json
}
@simt2
simt2 / templateData.go
Created February 21, 2017 08:11
mesh-go-example templateData
// templateData is the struct that we pass to our HTML templates, containing
// necessary data to render pages
type templateData struct {
Breadcrumb []gjson.Result
Category *gjson.Result
Products *[]gjson.Result
}
@simt2
simt2 / main.go
Last active February 27, 2017 06:53
mesh-go-example main logic
func main() {
// Log into the Gentics Mesh backend to retrieve session cookie
MeshLogin(USERNAME, PASSWORD)
// Set up router handling incoming requests
router := mux.NewRouter()
router.HandleFunc("/", IndexHandler)
router.HandleFunc("/{path:.*}", PathHandler)
loggedRouter := handlers.LoggingHandler(os.Stdout, router)