Skip to content

Instantly share code, notes, and snippets.

@s1s1ty s1s1ty/go-sql-route.go
Last active Aug 7, 2018

Embed
What would you like to do?
1st part
package main
import (
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
_ "github.com/go-sql-driver/mysql"
)
var router *chi.Mux
var db *sql.DB
const (
dbName = "go-mysql-crud"
dbPass = "12345"
dbHost = "localhost"
dbPort = "33066"
)
func routers() *chi.Mux {
router.Get("/posts", AllPosts)
router.Get("/posts/{id}", DetailPost)
router.Post("/posts", CreatePost)
router.Put("/posts/{id}", UpdatePost)
router.Delete("/posts/{id}", DeletePost)
return router
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.