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


Golang ObjectRequest.Controls方法代碼示例

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


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

示例1: getObjectRequest


//.........這裏部分代碼省略.........
		//isTokenValid, _ := validateSecurityToken(headerToken, headerNamespace)
		isTokenValid := true

		if isTokenValid {

			if r.Method != "GET" {
				rb, rerr := ioutil.ReadAll(r.Body)

				if rerr != nil {
					message = "Error converting request : " + rerr.Error()
					isSuccess = false
				} else {

					err := json.Unmarshal(rb, &requestBody)
					if err != nil {
						message = "JSON Parse error in Request : " + err.Error()
						isSuccess = false
					} else {
						objectRequest.Body = requestBody
					}
				}
			}

			if isSuccess {

				canAddHeader := true
				switch r.Method {
				case "GET": //read keyword, and unique key
					if len(headerId) != 0 {
						headerOperation = "read-key"
					} else if len(headerKeyword) != 0 {
						objectRequest.Body = messaging.RequestBody{}
						objectRequest.Body.Query = messaging.Query{Parameters: headerKeyword}
						headerOperation = "read-keyword"
					} else if len(headerNamespace) != 0 && len(headerClass) != 0 {
						headerOperation = "read-all"
					}
					canAddHeader = false
				case "POST": //read query, read special, insert
					if len(requestBody.Object) != 0 || len(requestBody.Objects) != 0 {
						fmt.Println("Insert by POST : " + objectRequest.Body.Parameters.KeyProperty)
						headerOperation = "insert"
						if len(objectRequest.Body.Object) != 0 {
							headerId = objectRequest.Body.Object[objectRequest.Body.Parameters.KeyProperty].(string)
						}
					} else if requestBody.Query.Type != "" && requestBody.Query.Type != " " {
						fmt.Println("Query Function Identified!")
						headerOperation = "read-filter"
						canAddHeader = false
					} else if requestBody.Special.Type != "" && requestBody.Special.Type != " " {
						fmt.Println("Special Function Identified!")
						headerOperation = "special"
						canAddHeader = false
					}

				case "PUT": //update
					if len(objectRequest.Body.Objects) != 0 {
						headerOperation = "update"
					} else {
						headerId = objectRequest.Body.Object[objectRequest.Body.Parameters.KeyProperty].(string)
						headerOperation = "update"
					}

				case "DELETE": //delete
					if len(objectRequest.Body.Objects) != 0 {
						headerOperation = "delete"
					} else {
						headerId = objectRequest.Body.Object[objectRequest.Body.Parameters.KeyProperty].(string)
						headerOperation = "delete"
					}
				}

				if len(objectRequest.Body.Objects) != 0 {
					headerMultipliciry = "multiple"
				} else if len(objectRequest.Body.Object) != 0 {
					headerMultipliciry = "single"
				}

				objectRequest.Controls = messaging.RequestControls{SecurityToken: headerToken, SendMetaData: sendMetaData, Namespace: headerNamespace, Class: headerClass, Multiplicity: headerMultipliciry, Id: headerId, Operation: headerOperation}

				configObject := configuration.ConfigurationManager{}.Get(headerToken, headerNamespace, headerClass)
				objectRequest.Configuration = configObject

				if canAddHeader {
					//This was changed on 2015-08-04
					//From now on headers will be added in repositories.RepositoryExecutor.go
					//Why this wasn't removed then? Without this note you could have deleted this.
					//SAVING IT FOR A RAINY DAY! Stop questioning the dev!
					repositories.FillControlHeaders(objectRequest)
				}
			}
		} else {
			isSuccess = false
			message = "Access token not validated." + missingFields
		}
	} else {
		message = "Missing attributes in request header : " + missingFields
	}
	return
}
開發者ID:sajeetharan,項目名稱:v6engine,代碼行數:101,代碼來源:HTTPService.go


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