コード例 #1
0
func init() {
	api, err := endpoints.RegisterService(&SwiftSampleApi{}, "swiftsampleapi", "v1", "Swift Sample API", true)

	if err != nil {
		panic(err.Error())
	}

	info := api.MethodByName("GetMessage").Info()
	info.Name, info.HttpMethod, info.Path, info.Desc = "message.get", "GET", "message", "Get greeting"

	info = api.MethodByName("PostMessage").Info()

	info.Name, info.HttpMethod, info.Path, info.Desc = "message.post", "POST", "message", "Post greeting"
	info.Scopes, info.Audiences, info.ClientIds = Scopes, Audiences, ClientIds

	endpoints.HandleHttp()
}
コード例 #2
0
ファイル: api.go プロジェクト: philips/go-endpoints
func init() {
	api := &TicTacToeApi{}
	rpcService, err := endpoints.RegisterService(api,
		"tictactoe", "v1", "Tic Tac Toe API", true)
	if err != nil {
		panic(err.Error())
	}

	info := rpcService.MethodByName("BoardGetMove").Info()
	info.Path, info.HttpMethod, info.Name, info.Scopes, info.ClientIds =
		"board", "POST", "board.getmove", defaultScopes, clientIds

	info = rpcService.MethodByName("ScoresList").Info()
	info.Path, info.HttpMethod, info.Name, info.Scopes, info.ClientIds =
		"scores", "GET", "scores.list", defaultScopes, clientIds

	info = rpcService.MethodByName("ScoresInsert").Info()
	info.Path, info.HttpMethod, info.Name, info.Scopes, info.ClientIds =
		"scores", "POST", "scores.insert", defaultScopes, clientIds

	endpoints.HandleHttp()
}
コード例 #3
0
ファイル: service.go プロジェクト: pcarleton/wustl-hack-2014
func registerCloudEndpoints() {
	// Create instance of our service
	service := &MessengerService{}

	// Register our service as an endpoint service
	api, err := endpoints.RegisterService(service, "messenger", "v1", "Messenger API", true)
	if err != nil {
		panic(err.Error())
	}

	// Register Echo method
	info := api.MethodByName("Echo").Info()
	info.Name, info.HttpMethod, info.Path, info.Desc =
		"Echo", "POST", "Echo", "Echoes your message."

	// Register Send method
	info = api.MethodByName("Send").Info()
	info.Name, info.HttpMethod, info.Path, info.Desc =
		"Send", "POST", "Send", "Sends your message to the specified device."

	// Start handling requests
	endpoints.HandleHttp()
}
コード例 #4
0
ファイル: service.go プロジェクト: philips/go-endpoints
func init() {
	greetService := &GreetingService{}
	rpcService, err := endpoints.RegisterServiceWithDefaults(greetService)
	if err != nil {
		panic(err.Error())
	}
	rpcService.Info().Name = "greeting"

	info := rpcService.MethodByName("List").Info()
	info.Name, info.HttpMethod, info.Path, info.Desc =
		"greets.list", "GET", "greetings", "List most recent greetings."

	info = rpcService.MethodByName("Sign").Info()
	info.Name, info.HttpMethod, info.Path, info.Desc =
		"greets.sign", "POST", "greetings", "Sign the guestbook."
	info.Scopes = []string{authScope}

	info = rpcService.MethodByName("Delete").Info()
	info.Name, info.HttpMethod, info.Path, info.Desc =
		"greets.delete", "DELETE", "greetings/{Id}", "Delete a single Greeting."

	info = rpcService.MethodByName("EchoGet").Info()
	info.Name, info.HttpMethod, info.Path =
		// These should match TestMessageGet field names
		"tests.echoGet", "GET", "tests/echo/{A}/{B}/{C}/{D}/{E}/{F}/{G}"

	info = rpcService.MethodByName("QueryEchoGet").Info()
	info.Name, info.HttpMethod, info.Path =
		"tests.queryEchoGet", "GET", "tests/query"

	info = rpcService.MethodByName("EchoPost").Info()
	info.Name, info.HttpMethod, info.Path =
		"tests.echoPost", "POST", "tests/echo"

	endpoints.HandleHttp()
}
コード例 #5
0
ファイル: main.go プロジェクト: rwl/go-tictactoe
func init() {
	if _, err := tictactoe.RegisterService(); err != nil {
		panic(err.Error())
	}
	endpoints.HandleHttp()
}