if i may a few fixes:

at the end change the line

http.ListenAndServe(":3000", router)


http.ListenAndServe(":3000", handler)

and the api as by convention it should be more like:

router.HandleFunc("/healthz", Healthz).Methods("GET")

router.HandleFunc("/todos/completed", GetCompletedItems).Methods("GET")

router.HandleFunc("/todos/incomplete", GetIncompleteItems).Methods("GET")

router.HandleFunc("/todos", CreateItem).Methods("POST")

router.HandleFunc("/todos/{id}", UpdateItem).Methods("PUT")

router.HandleFunc("/todos/{id}", DeleteItem).Methods("DELETE")

this is a very good article on how to REST API should be written


Full stack developer

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store