Skip to content

Commit c25bac8

Browse files
committed
typed register
1 parent c61c8b6 commit c25bac8

1 file changed

Lines changed: 25 additions & 22 deletions

File tree

pkg/github/query_handler.go

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,32 @@ func UnmarshalQuery(b []byte, v interface{}) *backend.DataResponse {
4242
// GetQueryHandlers creates the QueryTypeMux type for handling queries
4343
func GetQueryHandlers(s *QueryHandler) *datasource.QueryTypeMux {
4444
mux := datasource.NewQueryTypeMux()
45+
register := func(qt models.QueryType, handler backend.QueryDataHandlerFunc) {
46+
mux.HandleFunc(string(qt), handler)
47+
}
4548

46-
mux.HandleFunc(string(models.QueryTypeCommits), s.HandleCommits)
47-
mux.HandleFunc(string(models.QueryTypeIssues), s.HandleIssues)
48-
mux.HandleFunc(string(models.QueryTypeContributors), s.HandleContributors)
49-
mux.HandleFunc(string(models.QueryTypeLabels), s.HandleLabels)
50-
mux.HandleFunc(string(models.QueryTypePullRequests), s.HandlePullRequests)
51-
mux.HandleFunc(string(models.QueryTypePullRequestReviews), s.HandlePullRequestReviews)
52-
mux.HandleFunc(string(models.QueryTypeReleases), s.HandleReleases)
53-
mux.HandleFunc(string(models.QueryTypeTags), s.HandleTags)
54-
mux.HandleFunc(string(models.QueryTypePackages), s.HandlePackages)
55-
mux.HandleFunc(string(models.QueryTypeMilestones), s.HandleMilestones)
56-
mux.HandleFunc(string(models.QueryTypeRepositories), s.HandleRepositories)
57-
mux.HandleFunc(string(models.QueryTypeVulnerabilities), s.HandleVulnerabilities)
58-
mux.HandleFunc(string(models.QueryTypeProjects), s.HandleProjects)
59-
mux.HandleFunc(string(models.QueryTypeStargazers), s.HandleStargazers)
60-
mux.HandleFunc(string(models.QueryTypeWorkflows), s.HandleWorkflows)
61-
mux.HandleFunc(string(models.QueryTypeWorkflowUsage), s.HandleWorkflowUsage)
62-
mux.HandleFunc(string(models.QueryTypeWorkflowRuns), s.HandleWorkflowRuns)
63-
mux.HandleFunc(string(models.QueryTypeCodeScanning), s.HandleCodeScanning)
64-
mux.HandleFunc(string(models.QueryTypeDeployments), s.HandleDeployments)
65-
mux.HandleFunc(string(models.QueryTypeOrganizations), s.HandleOrganizations)
66-
mux.HandleFunc(string(models.QueryTypeCommitFiles), s.HandleCommitFiles)
67-
mux.HandleFunc(string(models.QueryTypePullRequestFiles), s.HandlePullRequestFiles)
49+
register(models.QueryTypeCommits, s.HandleCommits)
50+
register(models.QueryTypeIssues, s.HandleIssues)
51+
register(models.QueryTypeContributors, s.HandleContributors)
52+
register(models.QueryTypeLabels, s.HandleLabels)
53+
register(models.QueryTypePullRequests, s.HandlePullRequests)
54+
register(models.QueryTypePullRequestReviews, s.HandlePullRequestReviews)
55+
register(models.QueryTypeReleases, s.HandleReleases)
56+
register(models.QueryTypeTags, s.HandleTags)
57+
register(models.QueryTypePackages, s.HandlePackages)
58+
register(models.QueryTypeMilestones, s.HandleMilestones)
59+
register(models.QueryTypeRepositories, s.HandleRepositories)
60+
register(models.QueryTypeVulnerabilities, s.HandleVulnerabilities)
61+
register(models.QueryTypeProjects, s.HandleProjects)
62+
register(models.QueryTypeStargazers, s.HandleStargazers)
63+
register(models.QueryTypeWorkflows, s.HandleWorkflows)
64+
register(models.QueryTypeWorkflowUsage, s.HandleWorkflowUsage)
65+
register(models.QueryTypeWorkflowRuns, s.HandleWorkflowRuns)
66+
register(models.QueryTypeCodeScanning, s.HandleCodeScanning)
67+
register(models.QueryTypeDeployments, s.HandleDeployments)
68+
register(models.QueryTypeOrganizations, s.HandleOrganizations)
69+
register(models.QueryTypeCommitFiles, s.HandleCommitFiles)
70+
register(models.QueryTypePullRequestFiles, s.HandlePullRequestFiles)
6871

6972
return mux
7073
}

0 commit comments

Comments
 (0)