package main import ( "bytes" "encoding/json" "fmt" "net/http" "github.com/nilslice/cms/content" "github.com/nilslice/cms/management/editor" "github.com/nilslice/cms/management/manager" "github.com/nilslice/cms/system/admin" "github.com/nilslice/cms/system/db" ) func init() { http.HandleFunc("/admin", func(res http.ResponseWriter, req *http.Request) { adminView := admin.Admin(nil) res.Header().Set("Content-Type", "text/html") res.Write(adminView) }) http.HandleFunc("/admin/posts", func(res http.ResponseWriter, req *http.Request) { q := req.URL.Query() t := q.Get("type") if t == "" { res.WriteHeader(http.StatusBadRequest) } posts := db.GetAll(t) b := &bytes.Buffer{} p := content.Types[t]().(editor.Editable) html := `New ` + t + `