package main import ( "encoding/json" "log" "net/http" ) // Article type type Article struct { Title string `json:"title"` Description string `json:"description"` Content string `json:"content"` } // Articles Collection type Articles []Article func getAllArticles() http.Handler { fn := func(w http.ResponseWriter, r *http.Request) { articles := Articles{ Article{Title: "Test Title", Description: "Test Description", Content: "Hello content!"}, } json.NewEncoder(w).Encode(articles) log.Println("Served /articles") } return http.HandlerFunc(fn) }