示例#1
0
func (h *testServiceHandler) _http_TestService_FetchPerson(ctx golang_org_x_net_context.Context, rw net_http.ResponseWriter, req *net_http.Request) error {
	if req.Method != "GET" {
		return github_com_juju_errors.MethodNotAllowedf("expected GET request")
	}

	var (
		input  FetchOptions
		params = github_com_limbo_services_core_runtime_router.P(ctx)
	)

	ctx = github_com_limbo_services_core_runtime_limbo.AnnotateContext(ctx, req)

	// populate id
	{
		var msg0 = &input
		val := params.Get("id")
		intVal, _ := strconv.ParseInt(val, 10, 64)
		msg0.Id = int64(intVal)
	}

	{ // call
		output, err := h.ss.FetchPerson(ctx, &input)
		if err != nil {
			return github_com_juju_errors.Trace(err)
		}
		github_com_limbo_services_core_runtime_limbo.RenderMessageJSON(rw, 200, output)
		return nil
	}

	return nil
}
示例#2
0
func (h *testServiceHandler) _http_TestService_Greet(ctx golang_org_x_net_context.Context, rw net_http.ResponseWriter, req *net_http.Request) error {
	if req.Method != "POST" {
		return github_com_juju_errors.MethodNotAllowedf("expected POST request")
	}

	var (
		input Person
	)

	ctx = github_com_limbo_services_core_runtime_limbo.AnnotateContext(ctx, req)

	{ // from body
		err := encoding_json.NewDecoder(req.Body).Decode(&input)
		if err != nil {
			return github_com_juju_errors.Trace(err)
		}
	}

	{ // call
		output, err := h.ss.Greet(ctx, &input)
		if err != nil {
			return github_com_juju_errors.Trace(err)
		}
		github_com_limbo_services_core_runtime_limbo.RenderMessageJSON(rw, 200, output)
		return nil
	}

	return nil
}