From ebd1a89a588edf12d2ae746cebfc8c3474b738ba Mon Sep 17 00:00:00 2001 From: mountain Date: Thu, 26 Oct 2023 11:02:45 +0900 Subject: [PATCH] =?UTF-8?q?http=20api=20broker=20call=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server.go b/server.go index 08e8ec4..959ce7b 100644 --- a/server.go +++ b/server.go @@ -772,7 +772,18 @@ func (hc *HttpApiBroker) AddHandler(receiver HttpApiHandler) { } } -func (hc *HttpApiBroker) Call(funcname string, w http.ResponseWriter, r *http.Request) { +func (hc *HttpApiBroker) Call(w http.ResponseWriter, r *http.Request) { + funcname := r.URL.Query().Get("call") + if len(funcname) == 0 { + logger.Println("query param 'call' is missing") + w.WriteHeader(http.StatusBadRequest) + return + + } + hc.call(funcname, w, r) +} + +func (hc *HttpApiBroker) call(funcname string, w http.ResponseWriter, r *http.Request) { if found := hc.methods[funcname]; found != nil { found(w, r) } else {