tokers commented on a change in pull request #446:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/446#discussion_r632268619



##########
File path: pkg/kube/translation/annotations/cors.go
##########
@@ -14,37 +14,36 @@
 // limitations under the License.
 package annotations
 
-// CorsPlugin is the cors plugin.
-type CorsPlugin struct {
-       Origins string `json:"origins,omitempty"`
-       Headers string `json:"headers,omitempty"`
-       Methods string `json:"methods,omitempty"`
-       MaxAge  int64  `json:"max_age,omitempty"`
-}
+import (
+       apisixv1 
"github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
+)
 
-var (
+const (
        _enableCors       = "k8s.apisix.apache.org/enable-cors"
        _corsAllowOrigin  = "k8s.apisix.apache.org/cors-allow-origin"
        _corsAllowHeaders = "k8s.apisix.apache.org/cors-allow-headers"
        _corsAllowMethods = "k8s.apisix.apache.org/cors-allow-methods"
 )
 
-// BuildCorsPlugin build the cors plugin config body.
-func BuildCorsPlugin(annotations map[string]string) *CorsPlugin {
-       enable, ok := annotations[_enableCors]
-       if !ok || enable == "false" {
-               return nil
-       }
+type cors struct{}
 
-       var cors CorsPlugin
-       if ao, ok := annotations[_corsAllowOrigin]; ok {
-               cors.Origins = ao
-       }
-       if ah, ok := annotations[_corsAllowHeaders]; ok {
-               cors.Headers = ah
-       }
-       if am, ok := annotations[_corsAllowMethods]; ok {
-               cors.Methods = am
+// NewCorsHandler creates a handler to convert annotations about
+// cors to APISIX cors plugin.

Review comment:
       We use small case to represent a plugin name.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to