on going installation

This commit is contained in:
vanilia
2025-11-13 11:39:12 +07:00
parent 3e8a3610cf
commit 91afde0624
7 changed files with 22 additions and 76 deletions
@@ -74,67 +74,3 @@ func RegCrudByCode(r *http.ServeMux, path string, mwAndRouter ...any) {
"DELETE /{code}": c.Delete,
})
}
func RegCrudSimgosSync(r *http.ServeMux, path string, mwAndRouter ...any) {
sLength := len(mwAndRouter)
mwCandidates := mwAndRouter[:sLength-1]
mwList := []hk.HandlerMw{}
for i := range mwCandidates {
// have to do it manually, since casting directly results unexpected result
myType := reflect.TypeOf(mwCandidates[i])
if myType.String() != "func(http.Handler) http.Handler" {
panic("non middleware included as middleware")
}
mwList = append(mwList, mwCandidates[i].(func(http.Handler) http.Handler))
// if g, okHandler := mwCandidates[i].(func(http.Handler) http.Handler); !okHandler {
// panic("non middleware included")
// } else {
// mwList = append(mwList, g)
// }
}
c, ok := mwAndRouter[sLength-1].(CrudBase)
if !ok {
panic("non CrudBase used in the last paramter")
}
hk.GroupRoutes(path, r, mwList, hk.MapHandlerFunc{
"POST /": c.Create,
"PATCH /{id}": c.Update,
"DELETE /{id}": c.Delete,
})
}
func RegCrudByCodeSimgosSync(r *http.ServeMux, path string, mwAndRouter ...any) {
sLength := len(mwAndRouter)
mwCandidates := mwAndRouter[:sLength-1]
mwList := []hk.HandlerMw{}
for i := range mwCandidates {
// have to do it manually, since casting directly results unexpected result
myType := reflect.TypeOf(mwCandidates[i])
if myType.String() != "func(http.Handler) http.Handler" {
panic("non middleware included as middleware")
}
mwList = append(mwList, mwCandidates[i].(func(http.Handler) http.Handler))
// if g, okHandler := mwCandidates[i].(func(http.Handler) http.Handler); !okHandler {
// panic("non middleware included")
// } else {
// mwList = append(mwList, g)
// }
}
c, ok := mwAndRouter[sLength-1].(CrudBase)
if !ok {
panic("non CrudBase used in the last paramter")
}
hk.GroupRoutes(path, r, mwList, hk.MapHandlerFunc{
"POST /": c.Create,
"PATCH /{code}": c.Update,
"DELETE /{code}": c.Delete,
})
}