示例#1
0
func HandlePatchEnvironmentRequest(conf *http.HttpConfiguration, context *http.HttpContext, r *rest.Request) (interface{}, error) {
	id, errg := containers.NewIdentifier(r.PathParam("id"))
	if errg != nil {
		return nil, errg
	}
	data := containers.EnvironmentDescription{}
	if err := decodeAndCheck(r, &data); err != nil {
		return nil, err
	}
	data.Id = id
	return &cjobs.PatchEnvironmentRequest{data}, nil
}
示例#2
0
文件: handlers.go 项目: jhadvig/geard
func (h *HttpPatchEnvironmentRequest) Handler(conf *http.HttpConfiguration) http.JobHandler {
	return func(context *jobs.JobContext, r *rest.Request) (interface{}, error) {
		id, errg := containers.NewIdentifier(r.PathParam("id"))
		if errg != nil {
			return nil, errg
		}

		data := containers.EnvironmentDescription{}
		if r.Body != nil {
			dec := json.NewDecoder(limitedBodyReader(r))
			if err := dec.Decode(&data); err != nil && err != io.EOF {
				return nil, err
			}
		}
		if err := data.Check(); err != nil {
			return nil, err
		}
		data.Id = id

		return &cjobs.PatchEnvironmentRequest{data}, nil
	}
}