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


Golang Registration.MergeUpdate方法代碼示例

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


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

示例1: NewRegistration

func (wfe *WebFrontEndImpl) NewRegistration(response http.ResponseWriter, request *http.Request) {
	if request.Method != "POST" {
		wfe.sendError(response, "Method not allowed", "", http.StatusMethodNotAllowed)
		return
	}

	body, key, _, err := wfe.verifyPOST(request, false)
	if err != nil {
		wfe.sendError(response, "Unable to read/verify body", err, http.StatusBadRequest)
		return
	}

	var init, unmarshalled core.Registration
	err = json.Unmarshal(body, &unmarshalled)
	if err != nil {
		wfe.sendError(response, "Error unmarshaling JSON", err, http.StatusBadRequest)
		return
	}
	if len(unmarshalled.Agreement) > 0 && unmarshalled.Agreement != wfe.SubscriberAgreementURL {
		wfe.sendError(response, fmt.Sprintf("Provided agreement URL [%s] does not match current agreement URL [%s]", unmarshalled.Agreement, wfe.SubscriberAgreementURL), nil, http.StatusBadRequest)
		return
	}
	init.MergeUpdate(unmarshalled)

	reg, err := wfe.RA.NewRegistration(init, *key)
	if err != nil {
		wfe.sendError(response, "Error creating new registration", err, http.StatusInternalServerError)
		return
	}

	regURL := fmt.Sprintf("%s%s", wfe.RegBase, string(reg.ID))
	responseBody, err := json.Marshal(reg)
	if err != nil {
		wfe.sendError(response, "Error marshaling authz", err, http.StatusInternalServerError)
		return
	}

	response.Header().Add("Location", regURL)
	response.Header().Set("Content-Type", "application/json")
	response.Header().Add("Link", link(wfe.NewAuthz, "next"))
	if len(wfe.TermsPath) > 0 {
		response.Header().Add("Link", link(wfe.BaseURL+wfe.TermsPath, "terms-of-service"))
	}

	response.WriteHeader(http.StatusCreated)
	response.Write(responseBody)

	// incr reg stat
	wfe.Stats.Inc("Registrations", 1, 1.0)
}
開發者ID:hildjj,項目名稱:boulder,代碼行數:50,代碼來源:web-front-end.go

示例2: UpdateRegistration

// UpdateRegistration updates an existing Registration with new values.
func (ra *RegistrationAuthorityImpl) UpdateRegistration(base core.Registration, update core.Registration) (reg core.Registration, err error) {
	base.MergeUpdate(update)

	err = validateContacts(base.Contact, ra.DNSResolver)
	if err != nil {
		return
	}

	reg = base
	err = ra.SA.UpdateRegistration(base)
	if err != nil {
		// InternalServerError since the user-data was validated before being
		// passed to the SA.
		err = core.InternalServerError(fmt.Sprintf("Could not update registration: %s", err))
	}
	return
}
開發者ID:devpaul,項目名稱:boulder,代碼行數:18,代碼來源:registration-authority.go

示例3: UpdateRegistration

// UpdateRegistration updates an existing Registration with new values.
func (ra *RegistrationAuthorityImpl) UpdateRegistration(ctx context.Context, base core.Registration, update core.Registration) (reg core.Registration, err error) {
	base.MergeUpdate(update)

	err = ra.validateContacts(ctx, base.Contact)
	if err != nil {
		return
	}

	reg = base
	err = ra.SA.UpdateRegistration(ctx, base)
	if err != nil {
		// InternalServerError since the user-data was validated before being
		// passed to the SA.
		err = core.InternalServerError(fmt.Sprintf("Could not update registration: %s", err))
	}

	ra.stats.Inc("RA.UpdatedRegistrations", 1, 1.0)
	return
}
開發者ID:patf,項目名稱:boulder,代碼行數:20,代碼來源:registration-authority.go

示例4: UpdateRegistration

func (ra *RegistrationAuthorityImpl) UpdateRegistration(base core.Registration, update core.Registration) (reg core.Registration, err error) {
	base.MergeUpdate(update)
	reg = base
	err = ra.SA.UpdateRegistration(base)
	return
}
開發者ID:hildjj,項目名稱:boulder,代碼行數:6,代碼來源:registration-authority.go


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