Skip to content
Snippets Groups Projects

Resolve "Websocket utils"

Merged Jano Hendriks requested to merge 40-websocket-utils into main
3 files
+ 130
0
Compare changes
  • Side-by-side
  • Inline

Files

+ 22
0
@@ -43,6 +43,28 @@ func ValidateAPIEndpoints(endpoints map[string]map[string]interface{}) (map[stri
return endpoints, nil
}
// ValidateWebsocketEndpoints checks that all websocket endpoints are correctly defined using one of the supported
// handler types and returns updated endpoints with additional information
func ValidateWebsocketEndpoints(endpoints map[string]interface{}) (map[string]interface{}, error) {
for websocketAction, actionFunc := range endpoints {
if websocketAction == "" {
return nil, errors.Errorf("blank action")
}
if actionFunc == nil {
return nil, errors.Errorf("nil handler on %s %s", websocketAction, actionFunc)
}
handler, err := NewHandler(actionFunc)
if err != nil {
return nil, errors.Wrapf(err, "%s has invalid handler %T", websocketAction, actionFunc)
}
// replace the endpoint value so that we can quickly call this handler
endpoints[websocketAction] = handler
}
return endpoints, nil
}
func ValidateRequestParams(request *events.APIGatewayProxyRequest, paramsStructType reflect.Type) (reflect.Value, error) {
paramValues := map[string]interface{}{}
for n, v := range request.QueryStringParameters {
Loading