add Schema Disable Config #674 (#675)

* add schema disable config

* only forbid modify schema
diff --git a/frontend/schema/schemahandler.go b/frontend/schema/schemahandler.go
index 1a9a557..5a8f321 100644
--- a/frontend/schema/schemahandler.go
+++ b/frontend/schema/schemahandler.go
@@ -27,7 +27,18 @@
 	"github.com/labstack/echo"
 )
 
-func SchemaHandleFunc(c echo.Context) (err error) {
+type Mux struct {
+	// Disable represents frontend proxy service api or not
+	Disable bool
+}
+
+func (m *Mux) SchemaHandleFunc(c echo.Context) (err error) {
+	if m.Disable {
+		c.Response().WriteHeader(http.StatusForbidden)
+		_, _ = c.Response().Write([]byte("schema is disabled"))
+		return
+	}
+
 	r := c.Request()
 
 	//	protocol:= r.Header.Get("X-InstanceProtocol")
diff --git a/frontend/server.go b/frontend/server.go
index e527537..00c7623 100644
--- a/frontend/server.go
+++ b/frontend/server.go
@@ -38,7 +38,8 @@
 	staticPath := filepath.Join(dir, "app")
 	e.Static("/", staticPath)
 
-	e.Any("/testSchema/*", schema.SchemaHandleFunc)
+	m := schema.Mux{Disable: os.Getenv("SCHEMA_DISABLE") == "true"}
+	e.Any("/testSchema/*", m.SchemaHandleFunc)
 
 	scProxy(c, e)
 
diff --git a/server/core/config.go b/server/core/config.go
index 89d569c..b1ffa29 100644
--- a/server/core/config.go
+++ b/server/core/config.go
@@ -139,6 +139,8 @@
 			ServiceClearEnabled:  os.Getenv("SERVICE_CLEAR_ENABLED") == "true",
 			ServiceClearInterval: serviceClearInterval,
 			ServiceTTL:           serviceTTL,
+
+			SchemaDisable: os.Getenv("SCHEMA_DISABLE") == "true",
 		},
 	}
 }
diff --git a/server/core/proto/types.go b/server/core/proto/types.go
index c301032..a2dc148 100644
--- a/server/core/proto/types.go
+++ b/server/core/proto/types.go
@@ -67,6 +67,9 @@
 	ServiceTTL time.Duration `json:"serviceTTL"`
 	//CacheTTL is the ttl of cache
 	CacheTTL time.Duration `json:"cacheTTL"`
+
+	// if want disable Test Schema, SchemaDisable set true
+	SchemaDisable bool `json:"schemaDisable"`
 }
 
 type ServerInformation struct {
diff --git a/server/rest/controller/v4/schema_controller.go b/server/rest/controller/v4/schema_controller.go
index e059794..cefc20d 100644
--- a/server/rest/controller/v4/schema_controller.go
+++ b/server/rest/controller/v4/schema_controller.go
@@ -36,13 +36,25 @@
 }
 
 func (s *SchemaService) URLPatterns() []rest.Route {
-	return []rest.Route{
+	var r = []rest.Route{
 		{Method: rest.HTTPMethodGet, Path: "/v4/:project/registry/microservices/:serviceId/schemas/:schemaId", Func: s.GetSchemas},
-		{Method: rest.HTTPMethodPut, Path: "/v4/:project/registry/microservices/:serviceId/schemas/:schemaId", Func: s.ModifySchema},
 		{Method: rest.HTTPMethodDelete, Path: "/v4/:project/registry/microservices/:serviceId/schemas/:schemaId", Func: s.DeleteSchemas},
 		{Method: rest.HTTPMethodPost, Path: "/v4/:project/registry/microservices/:serviceId/schemas", Func: s.ModifySchemas},
 		{Method: rest.HTTPMethodGet, Path: "/v4/:project/registry/microservices/:serviceId/schemas", Func: s.GetAllSchemas},
 	}
+
+	if !core.ServerInfo.Config.SchemaDisable {
+		r = append(r, rest.Route{Method: rest.HTTPMethodPut, Path: "/v4/:project/registry/microservices/:serviceId/schemas/:schemaId", Func: s.ModifySchema})
+	} else {
+		r = append(r, rest.Route{Method: rest.HTTPMethodPut, Path: "/v4/:project/registry/microservices/:serviceId/schemas/:schemaId", Func: s.DisableSchema})
+	}
+
+	return r
+}
+
+func (s *SchemaService) DisableSchema(w http.ResponseWriter, r *http.Request) {
+	w.WriteHeader(http.StatusForbidden)
+	_, _ = w.Write([]byte("schema modify is disabled"))
 }
 
 func (s *SchemaService) GetSchemas(w http.ResponseWriter, r *http.Request) {