Skip to content

elimsc/goe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goe

Go extend.

$ go get https://github.com/elimsc/goe

chie:

var r = chi.NewRouter()
var sess sqlbuilder.Database  // see https://upper.io/db.v3

chie.CrudController

var categoryController = chie.CrudController{
    Sess:      sess,
    GetParam:  chi.URLParam,
    TableName: "category",
}

r.Route("/categories", func(r chi.Router) {
    r.Get("/", categoryController.Pagination)
    r.Get("/{id}", categoryController.One)
    r.Post("/", categoryController.Create)
    r.Put("/", categoryController.Update)
    r.Delete("/{id}", categoryController.Delete)
    r.Get("/all", categoryController.All)
})

chie.CrudTable

chie.CrudTable(r, sess, "demo", "/hi/demo")
// GET /hi/demo       list 
// POST /hi/demo      create
// GET /hi/demo/{id}  one
// PUT /hi/demo      update
// GET /hi/demo/all  all
// POST /hi/update   update

chie.CrudDb*

chie.CrudDBAll(r, sess)
chie.CrudDBOnly(r, sess, []string{"demo"})
chie.CrudDBExcept(r, sess, []string{"demo"})
// for _, table := range tables {
//    chiu.CrudTable(r, sess, table, "/"+table)
// }

chie.FileServer

workDir, _ := os.Getwd()
filesDir := filepath.Join(workDir, "files")
chie.FileServer(r, "/files", http.Dir(filesDir))

// same as
chie.ServeStatic(r, "/files", "files")

About

A simple go util package.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages