本文整理匯總了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
}
示例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
}
示例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
}
示例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
}
示例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
}