Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgroup-go-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bob Public Utils
bobgroup-go-utils
Merge requests
!49
Resolve "Websocket utils"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Resolve "Websocket utils"
40-websocket-utils
into
main
Overview
0
Commits
1
Pipelines
0
Changes
3
Merged
Jano Hendriks
requested to merge
40-websocket-utils
into
main
1 year ago
Overview
0
Commits
1
Pipelines
0
Changes
3
Related to
#40 (closed)
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
02882f75
1 commit,
1 year ago
3 files
+
130
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
handler_utils/api.go
+
22
−
0
View file @ 02882f75
Edit in single-file editor
Open in Web IDE
Show full file
@@ -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