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()
}
Example #2
0
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()
}
Example #3
0
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()
}
Example #4
0
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()
}
Example #5
0
func init() {
	if _, err := tictactoe.RegisterService(); err != nil {
		panic(err.Error())
	}
	endpoints.HandleHttp()
}