コード例 #1
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
	}
}