Improve tests and speed things up a little.

This commit is contained in:
2023-11-20 11:38:02 +00:00
parent b4c047819f
commit bc305dd8e9
5 changed files with 70 additions and 15 deletions
+10
View File
@@ -38,6 +38,7 @@ var introspection_queries = []string{
var introspectionQuerySet = map[string]struct{}{}
var introspectionAllowedQueries = map[string]struct{}{}
var allowedUrls = map[string]struct{}{}
func prepareQueriesAndExemptions() {
introspectionQuerySet = map[string]struct{}{}
@@ -57,6 +58,15 @@ func prepareQueriesAndExemptions() {
}
return rsqs
}()
allowedUrls = map[string]struct{}{}
allowedUrls = func() map[string]struct{} {
rsqs := make(map[string]struct{}, len(cfg.Server.AllowURLs))
for _, query := range cfg.Server.AllowURLs {
rsqs[strings.ToLower(query)] = struct{}{}
}
return rsqs
}()
}
func parseGraphQLQuery(c *fiber.Ctx) (operationType, operationName string, cacheRequest bool, cache_time int, should_block bool, should_ignore bool) {