當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ManifestParameters.ValidateFetch方法代碼示例

本文整理匯總了Golang中mig/ninja/mig.ManifestParameters.ValidateFetch方法的典型用法代碼示例。如果您正苦於以下問題:Golang ManifestParameters.ValidateFetch方法的具體用法?Golang ManifestParameters.ValidateFetch怎麽用?Golang ManifestParameters.ValidateFetch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mig/ninja/mig.ManifestParameters的用法示例。


在下文中一共展示了ManifestParameters.ValidateFetch方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: getManifestFile

// API entry point used to request a file be sent to the loader from the API.
// This would typically be called from a loader after it has received a
// manifest and determined updates to file system objects are required.
func getManifestFile(respWriter http.ResponseWriter, request *http.Request) {
	loc := fmt.Sprintf("%s%s", ctx.Server.Host, request.URL.String())
	opid := getOpID(request)
	resource := cljs.New(loc)
	defer func() {
		if e := recover(); e != nil {
			ctx.Channels.Log <- mig.Log{OpID: opid, Desc: fmt.Sprintf("%v", e)}.Err()
			resource.SetError(cljs.Error{Code: fmt.Sprintf("%.0f", opid), Message: fmt.Sprintf("%v", e)})
			respond(http.StatusInternalServerError, resource, respWriter, request)
		}
		ctx.Channels.Log <- mig.Log{OpID: opid, Desc: "leaving getManifestFile()"}.Debug()
	}()
	err := request.ParseForm()
	if err != nil {
		panic(err)
	}

	ctx.Channels.Log <- mig.Log{OpID: opid, Desc: fmt.Sprintf("Received manifest file request")}.Debug()

	var manifestParam mig.ManifestParameters
	err = json.Unmarshal([]byte(request.FormValue("parameters")), &manifestParam)
	if err != nil {
		panic(err)
	}
	err = manifestParam.ValidateFetch()
	if err != nil {
		panic(err)
	}

	loaderid := getLoaderID(request)
	if loaderid == 0 {
		panic("Request has no valid loader ID")
	}
	ctx.Channels.Log <- mig.Log{OpID: opid,
		Desc: fmt.Sprintf("Loader request from %v for %v",
			loaderid, manifestParam.Object)}.Debug()

	// Update the loader entry with the parameters, and locate a valid manifest
	mf, err := locateManifestFromLoader(loaderid, manifestParam.AgentIdentifier)
	if err != nil {
		panic(err)
	}
	data, err := mf.ManifestObject(manifestParam.Object)
	if err != nil {
		panic(err)
	}
	fetchresp := mig.ManifestFetchResponse{Data: data}

	// Send the response to the loader
	err = resource.AddItem(cljs.Item{
		Href: request.URL.String(),
		Data: []cljs.Data{
			{
				Name:  "content",
				Value: fetchresp,
			},
		}})
	if err != nil {
		panic(err)
	}
	respond(http.StatusOK, resource, respWriter, request)
}
開發者ID:saakaifoundry,項目名稱:mig,代碼行數:65,代碼來源:manifest_endpoints.go


注:本文中的mig/ninja/mig.ManifestParameters.ValidateFetch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。