Service center(SC) support an extend modules mechanism that developers can new some features in SC easily.
Implement the ROAServantService interface.
package hello import ( "net/http" "github.com/apache/servicecomb-service-center/pkg/rest" ) type HelloService struct { } func (s *HelloService) URLPatterns() []rest.Route { return []rest.Route{ { rest.HTTP_METHOD_GET, // Method is one of the following: GET,PUT,POST,DELETE "/helloWorld", // Path contains a path pattern s.SayHello, // rest callback function for the specified Method and Path }, } } func (s *HelloService) SayHello(w http.ResponseWriter, r *http.Request) { // say Hi }
Register the service in SC ROA framework when the module initializes.
package hello
import roa "github.com/apache/servicecomb-service-center/pkg/rest"
func init() {
roa.RegisterServent(&HelloService{})
}
Modify bootstarp.go file to import your module.
// module import _ "github.com/apache/servicecomb-service-center/server/hello"
To see govern module for help.