Пример #1
0
// Register the API endpoints
func init() {
	taskService := &TaskService{}
	// Adds the TaskService to the server.
	api, err := endpoints.RegisterService(
		taskService,
		"tasks",
		"v1",
		"Tasks API",
		true,
	)
	if err != nil {
		log.Fatalf("Register service: %v", err)
	}

	// Get ServiceMethod's MethodInfo for List method
	info := api.MethodByName("List").Info()
	// Provide values to MethodInfo - name, HTTP method, and path.
	info.Name, info.HTTPMethod, info.Path = "listTasks", "GET", "tasks"

	// Get ServiceMethod's MethodInfo for Add method
	info = api.MethodByName("Add").Info()
	info.Name, info.HTTPMethod, info.Path = "addTask", "POST", "tasks"
	// Calls DefaultServer's HandleHttp method using default serve mux
	endpoints.HandleHTTP()
}
Пример #2
0
func init() {
	_, err := endpoints.RegisterService(ChannelsAPI{}, "channels", "v1", "channels API", true)
	if err != nil {
		panic(err)
	}
	endpoints.HandleHTTP()
}
Пример #3
0
func init() {
	// register the posts API with cloud endpoints.
	api, err := endpoints.RegisterService(PostsAPI{}, "posts", "v1", "posts api", true)
	if err != nil {
		log.Fatal(err)
	}

	// adapt the name, method, and path for each method.
	info := api.MethodByName("List").Info()
	info.Name, info.HTTPMethod, info.Path = "getPosts", "GET", "posts"

	info = api.MethodByName("SetFavorite").Info()
	info.Name, info.HTTPMethod, info.Path = "setFavorite", "PUT", "posts"

	info = api.MethodByName("Add").Info()
	info.Name, info.HTTPMethod, info.Path = "addPost", "POST", "posts"

	// start handling cloud endpoint requests.
	endpoints.HandleHTTP()
}
Пример #4
0
func init() {
	service := &BatteryService{}
	api, err := endpoints.RegisterService(service, "", "v1", "Battery API", true)
	if err != nil {
		logger.Fatalf("Register service: %v", err)
	}

	register := func(orig, name, method, path, desc string) {
		m := api.MethodByName(orig)
		if m == nil {
			logger.Fatalf("Missing method %s", orig)
		}
		i := m.Info()
		i.Name, i.HTTPMethod, i.Path, i.Desc = name, method, path, desc
	}

	register("Update", "update", "POST", "battery", "Update battery history.")
	register("Hello", "hello", "GET", "battery", "Hello battery history.")
	endpoints.HandleHTTP()
}
Пример #5
0
func init() {
	api, err := endpoints.RegisterService(&GreetingService{},
		"greetings", "v1", "Greetings API", true)
	if err != nil {
		log.Fatalf("Register service: %v", err)
	}

	list := api.MethodByName("List").Info()
	list.HTTPMethod = "GET"
	list.Path = "greetings"
	list.Name = "list"
	list.Desc = "List most recent greetings."

	add := api.MethodByName("Add").Info()
	add.HTTPMethod = "PUT"
	add.Path = "greetings"
	add.Name = "add"
	add.Desc = "Add a greeting."

	endpoints.HandleHTTP()
}
Пример #6
0
func init() {
	http.Handle("/api/certification", newHandler(apiCertificationGet))

	http.Handle("/api/certificationClass", newHandler(apiCertificationClassGet))
	http.Handle("/api/certificationClass/all", newHandler(apiCertificationClassGetAll))
	http.Handle("/api/certificationClass/save", newHandler(apiCertificationClassSave))
	http.Handle("/api/certificationClass/attendee/add", newHandler(apiCertificationClassAttendeeAdd))

	http.Handle("/api/comfort-station/", newHandler(apiComfortStation))
	http.Handle("/api/comfort-stations/", newHandler(apiComfortStationsAll))

	http.Handle("/api/member", newHandler(memberData))
	http.Handle("/api/member/save", newHandler(apiMemberSave))
	http.Handle("/api/member/toggle-active", newHandler(apiMemberToggleActive))
	http.Handle("/api/member/toggle-enabled", newHandler(apiMemberToggleEnabled))
	http.Handle("/api/member/search", newHandler(apiMemberSearch))
	http.Handle("/api/member/calledBy", newHandler(apiMemberCalledBy))

	http.Handle("/api/team/save", newHandler(apiTeamSave))

	http.Handle("/api/trainingTopic/save", newHandler(apiTrainingTopicSave))

	//http.Handle("/api/where/lookup", newHandler(apiWhereLookup))

	http.Handle("/audit", newHandler(audit))
	http.Handle("/certifications/all", newHandler(certificationsGetAll))
	http.Handle("/certification/save", newHandler(certificationSave))
	http.Handle("/eventA", newHandler(eventA))
	http.Handle("/event", newHandler(event))
	http.Handle("/event/reminders/send", newHandler(remindersSend))
	http.Handle("/event/save", newHandler(eventSave))
	http.Handle("/events", newHandler(events))
	http.Handle("/response", newHandler(response))
	http.Handle("/response/save", newHandler(responseSave))
	http.Handle("/responses/create", newHandler(responsesCreate))
	http.Handle("/team", newHandler(teamData))
	http.Handle("/team/roster", newHandler(teamRoster))
	http.Handle("/team/roster/import", newHandler(membersImport))
	http.Handle("/fix/teamMembers/without/Member", newHandler(fixData))
	http.Handle("/fix/members/geocode", newHandler(resaveMembers))
	http.Handle("/address", newHandler(locationLookupHandler))
	http.Handle("/setup", newHandler(initialSetup))
	http.Handle("/", newHandler(root))

	http.Handle("/whereami", newHandler(whereAmI))
	http.Handle("/whereami/save", newHandler(whereAmISave))

	whereService := &WhereAmIService{}
	// was api, err
	_, err := endpoints.RegisterService(whereService, "where", "v1", "Where Am I? API", true)
	if err != nil {
		log.Fatalf("Register service: %v", err)
	}

	// register := func(orig, name, method, path, desc string) {
	// 	m := api.MethodByName(orig)
	// 	if m == nil {
	// 		log.Fatalf("Missing method %s", orig)
	// 	}
	// 	i := m.Info()
	// 	i.Name, i.HTTPMethod, i.Path, i.Desc = name, method, path, desc
	// }

	// register("List", "greets.list", "GET", "greetings", "List most recent greetings.")
	// register("Add", "greets.add", "PUT", "greetings", "Add a greeting.")
	// register("Count", "greets.count", "GET", "greetings/count", "Count all greetings.")
	endpoints.HandleHTTP()

	rand.Seed(time.Now().UnixNano())
}
Пример #7
0
func init() {
	http.HandleFunc("/", handler)
	example.RegisterEndpointsService(endpoints.DefaultServer)
	endpoints.HandleHTTP()
}