함수 이름을 인자로 받음

This commit is contained in:
2023-09-05 16:43:34 +09:00
parent 3a3839a461
commit 7951814f12

View File

@ -682,12 +682,10 @@ func (hc *HttpApiHandlerContainer) RegistReceiver(receiver HttpApiReceiver) {
}
}
func (hc *HttpApiHandlerContainer) Call(w http.ResponseWriter, r *http.Request) {
lastSlash := strings.LastIndex(r.URL.Path, "/")
fname := r.URL.Path[lastSlash:]
if found := hc.methods[fname]; found != nil {
func (hc *HttpApiHandlerContainer) Call(funcname string, w http.ResponseWriter, r *http.Request) {
if found := hc.methods[funcname]; found != nil {
found(w, r)
} else {
logger.Println("api is not found :", fname)
logger.Println("api is not found :", funcname)
}
}