Closed GuilhermeFirmiano closed 5 years ago
w.Header().Set("Content-Type", "application/x-amz-json-1.1")
h := handler.NewRequestHandler(r, logger, database)
split := strings.Split(r.Header.Get("X-Amz-Target"), ".")
method := reflect.ValueOf(h).MethodByName(split[1])
if method.IsValid() {
result := method.Call([]reflect.Value{})
response := result[0].Interface().(handler.Response)
respond(w, response)
}
error501(w)
Thank you for the feedback @GuilhermeFirmiano. You're right, that switch statement is a little unwieldy. I'll take a look over at what you're suggesting.
Hi @GuilhermeFirmiano. Thank you again for the feedback. I've just pushed the change.
You could use reflection