on going installation
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user