当前位置: 首页>>代码示例>>Golang>>正文


Golang ObjectRequest.IsLogEnabled方法代码示例

本文整理汇总了Golang中duov6/com/objectstore/messaging.ObjectRequest.IsLogEnabled方法的典型用法代码示例。如果您正苦于以下问题:Golang ObjectRequest.IsLogEnabled方法的具体用法?Golang ObjectRequest.IsLogEnabled怎么用?Golang ObjectRequest.IsLogEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在duov6/com/objectstore/messaging.ObjectRequest的用法示例。


在下文中一共展示了ObjectRequest.IsLogEnabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: getObjectRequest

func getObjectRequest(r *http.Request, objectRequest *messaging.ObjectRequest, params martini.Params) (message string, isSuccess bool) {

	missingFields := ""
	isSuccess = true

	headerToken := r.Header.Get("securityToken")
	sendMetaData := r.Header.Get("sendMetaData")
	headerLog := r.Header.Get("log")

	var headerOperation string
	headerMultipliciry := r.Header.Get("multiplicity")

	headerNamespace := params["namespace"]
	headerClass := params["class"]

	headerId := params["id"]
	headerKeyword := r.URL.Query().Get("keyword")

	//check if <Skip> and <Take> are specified
	//If so store them in ObjectRequest <Extras>

	if r.URL.Query().Get("skip") != "" {
		objectRequest.Extras["skip"] = r.URL.Query().Get("skip")
	}

	if r.URL.Query().Get("take") != "" {
		objectRequest.Extras["take"] = r.URL.Query().Get("take")
	}

	if r.URL.Query().Get("fieldName") != "" {
		objectRequest.Extras["fieldName"] = r.URL.Query().Get("fieldName")
	}

	if len(headerToken) == 0 {
		isSuccess = false
		missingFields = missingFields + "securityToken"
	}

	if len(headerLog) != 0 {
		objectRequest.IsLogEnabled = true
		var initialSlice []string
		initialSlice = make([]string, 0)
		objectRequest.MessageStack = initialSlice
	} else {
		objectRequest.IsLogEnabled = false
	}

	var requestBody messaging.RequestBody

	if isSuccess {

		//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
//.........这里部分代码省略.........
开发者ID:sajeetharan,项目名称:v6engine,代码行数:101,代码来源:HTTPService.go


注:本文中的duov6/com/objectstore/messaging.ObjectRequest.IsLogEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。