コード例 #1
0
func (controller *DemoController) Read(idString string, ctx context.Context) error {
	log.Print("Responding to request for item details")
	messages := rest_codecs.NewMessageMap()
	messages.AddInfoMessage("Found item for id " + idString)
	return rest_codecs.Respond(ctx, http.StatusOK, messages, map[string]interface{}{
		"description": "This is the " + idString + " item",
		"name":        idString,
		"details":     "I am some details that are not very detailed because this is a demo",
	})
}
コード例 #2
0
func (controller *DemoController) ReadMany(ctx context.Context) error {
	log.Print("Responding to request for item list.")
	messages := rest_codecs.NewMessageMap()
	return rest_codecs.Respond(ctx, http.StatusOK, messages, []interface{}{
		map[string]string{
			"description": "This is the first item",
			"link":        controller.Path() + "/first",
		},
		map[string]string{
			"description": "This is the second item",
			"link":        controller.Path() + "/second",
		},
	})
}