코드 정리 및 websocket도 http와 비슷하게 api handler로 통일

This commit is contained in:
2023-09-08 11:35:57 +09:00
parent eb54fa2e3a
commit 6cbf32c386
10 changed files with 216 additions and 130 deletions

View File

@ -618,11 +618,11 @@ func MakeHttpRequestForLogging(r *http.Request) *http.Request {
}
type apiFuncType func(http.ResponseWriter, *http.Request)
type HttpApiReceiver struct {
type HttpApiHandler struct {
methods map[string]apiFuncType
}
func MakeHttpApiReceiver[T any](receiver *T, receiverName string) HttpApiReceiver {
func MakeHttpApiHandler[T any](receiver *T, receiverName string) HttpApiHandler {
methods := make(map[string]apiFuncType)
tp := reflect.TypeOf(receiver)
@ -662,7 +662,7 @@ func MakeHttpApiReceiver[T any](receiver *T, receiverName string) HttpApiReceive
}
}
return HttpApiReceiver{
return HttpApiHandler{
methods: methods,
}
}
@ -671,7 +671,7 @@ type HttpApiHandlerContainer struct {
methods map[string]apiFuncType
}
func (hc *HttpApiHandlerContainer) RegistReceiver(receiver HttpApiReceiver) {
func (hc *HttpApiHandlerContainer) RegisterApiHandler(receiver HttpApiHandler) {
if hc.methods == nil {
hc.methods = make(map[string]apiFuncType)
}