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


Golang Request.SetFormParam方法代碼示例

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


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

示例1: WriteToRequest

// WriteToRequest writes these params to a swagger request
func (o *UploadTaskFileParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {

	var res []error

	// form param description
	frDescription := o.Description
	fDescription := frDescription
	if fDescription != "" {
		if err := r.SetFormParam("description", fDescription); err != nil {
			return err
		}
	}

	if o.File != nil {
		// form file param file
		if err := r.SetFileParam("file", o.File); err != nil {
			return err
		}
	}

	// path param id
	if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
		return err
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
開發者ID:MStoykov,項目名稱:go-swagger,代碼行數:31,代碼來源:upload_task_file_parameters.go

示例2: WriteToRequest

// WriteToRequest writes these params to a swagger request
func (o *FindParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {

	var res []error

	// header param X-Rate-Limit
	if err := r.SetHeaderParam("X-Rate-Limit", swag.FormatInt32(o.XRateLimit)); err != nil {
		return err
	}

	// form param limit
	frLimit := o.Limit
	fLimit := swag.FormatInt32(frLimit)
	if err := r.SetFormParam("limit", fLimit); err != nil {
		return err
	}

	var valuesTags []string
	for _, v := range o.Tags {
		valuesTags = append(valuesTags, swag.FormatInt32(v))
	}

	joinedTags := swag.JoinByFormat(valuesTags, "multi")
	// form array param tags
	if err := r.SetFormParam("tags", joinedTags...); err != nil {
		return err
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
開發者ID:jemkzheng,項目名稱:go-swagger,代碼行數:33,代碼來源:find_parameters.go

示例3: WriteToRequest

// WriteToRequest writes these params to a swagger request
// API: POST /api/social/tweet/{id}/comment
func (o *TweetCommentParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {
	// path param name
	if err := r.SetPathParam("social", "tweet"); err != nil {
		return err
	}
	if err := r.SetPathParam(fmt.Sprintf("%d", o.Id), "comment"); err != nil {
		return err
	}
	if err := r.SetFormParam("content", o.Content); err != nil {
		return err
	}
	if err := r.SetFormParam("afterFilter", o.AfterFilter); err != nil {
		return err
	}
	return nil
}
開發者ID:wangfeiping,項目名稱:go-coding,代碼行數:18,代碼來源:tweet_comment_parameters.go

示例4: WriteToRequest

// WriteToRequest writes these params to a swagger request
// API: DELETE /api/social/tweet/{id}/comment/{comment_id}
func (o *TweetCommentDelParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {
	// path param name
	if err := r.SetPathParam("social/tweet",
		fmt.Sprintf("%d", o.TweetId)); err != nil {
		return err
	}
	if err := r.SetPathParam("comment",
		fmt.Sprintf("%d", o.CommentId)); err != nil {
		return err
	}
	if err := r.SetFormParam("comment",
		fmt.Sprintf("%d", o.CommentId)); err != nil {
		return err
	}
	return nil
}
開發者ID:wangfeiping,項目名稱:go-coding,代碼行數:18,代碼來源:tweet_comment_del_parameters.go

示例5: WriteToRequest

// WriteToRequest writes these params to a swagger request
// API: POST /api/social/tweet
func (o *TweetCreateParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {
	// path param name
	if err := r.SetPathParam("social", "tweet"); err != nil {
		return err
	}
	if err := r.SetFormParam("device", o.Device); err != nil {
		return err
	}
	if err := r.SetFormParam("location", o.Location); err != nil {
		return err
	}
	if err := r.SetFormParam("coord", o.Coord); err != nil {
		return err
	}
	if err := r.SetFormParam("address", o.Address); err != nil {
		return err
	}
	if err := r.SetFormParam("content", o.Content); err != nil {
		return err
	}
	return nil
}
開發者ID:wangfeiping,項目名稱:go-coding,代碼行數:24,代碼來源:tweet_create_parameters.go


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