diff --git a/pkg/search/storage/types.go b/pkg/search/storage/types.go index a6559dcc..6c101daf 100644 --- a/pkg/search/storage/types.go +++ b/pkg/search/storage/types.go @@ -21,9 +21,9 @@ import ( ) const ( - Equals string = "=" - DSLPatternType = "dsl" - SQLPatternType = "sql" + Equals = "=" + DSLPatternType = "dsl" + SQLPatternType = "sql" ) type Storage interface { diff --git a/pkg/util/filters/search_filter.go b/pkg/util/filters/search_filter.go index 50d316a8..c2dcdf91 100644 --- a/pkg/util/filters/search_filter.go +++ b/pkg/util/filters/search_filter.go @@ -21,6 +21,8 @@ import ( "github.com/KusionStack/karbour/pkg/search/storage" ) +type ctxTyp string + const ( searchQueryKey = "query" patternTypeKey = "patternType" @@ -63,6 +65,5 @@ func FromQueryToContext(req *http.Request, key string, defaultVal string) *http. query.Del(key) val = queryVal[0] } - - return req.WithContext(context.WithValue(req.Context(), key, val)) + return req.WithContext(context.WithValue(req.Context(), ctxTyp(key), val)) }