github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/examples/auto-configure/restapi/operations/todos/find_todos_urlbuilder.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package todos 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the generate command 7 8 import ( 9 "errors" 10 "net/url" 11 golangswaggerpaths "path" 12 13 "github.com/go-openapi/swag" 14 ) 15 16 // FindTodosURL generates an URL for the find todos operation 17 type FindTodosURL struct { 18 Limit *int32 19 Since *int64 20 21 _basePath string 22 // avoid unkeyed usage 23 _ struct{} 24 } 25 26 // WithBasePath sets the base path for this url builder, only required when it's different from the 27 // base path specified in the swagger spec. 28 // When the value of the base path is an empty string 29 func (o *FindTodosURL) WithBasePath(bp string) *FindTodosURL { 30 o.SetBasePath(bp) 31 return o 32 } 33 34 // SetBasePath sets the base path for this url builder, only required when it's different from the 35 // base path specified in the swagger spec. 36 // When the value of the base path is an empty string 37 func (o *FindTodosURL) SetBasePath(bp string) { 38 o._basePath = bp 39 } 40 41 // Build a url path and query string 42 func (o *FindTodosURL) Build() (*url.URL, error) { 43 var _result url.URL 44 45 var _path = "/" 46 47 _basePath := o._basePath 48 _result.Path = golangswaggerpaths.Join(_basePath, _path) 49 50 qs := make(url.Values) 51 52 var limitQ string 53 if o.Limit != nil { 54 limitQ = swag.FormatInt32(*o.Limit) 55 } 56 if limitQ != "" { 57 qs.Set("limit", limitQ) 58 } 59 60 var sinceQ string 61 if o.Since != nil { 62 sinceQ = swag.FormatInt64(*o.Since) 63 } 64 if sinceQ != "" { 65 qs.Set("since", sinceQ) 66 } 67 68 _result.RawQuery = qs.Encode() 69 70 return &_result, nil 71 } 72 73 // Must is a helper function to panic when the url builder returns an error 74 func (o *FindTodosURL) Must(u *url.URL, err error) *url.URL { 75 if err != nil { 76 panic(err) 77 } 78 if u == nil { 79 panic("url can't be nil") 80 } 81 return u 82 } 83 84 // String returns the string representation of the path with query string 85 func (o *FindTodosURL) String() string { 86 return o.Must(o.Build()).String() 87 } 88 89 // BuildFull builds a full url with scheme, host, path and query string 90 func (o *FindTodosURL) BuildFull(scheme, host string) (*url.URL, error) { 91 if scheme == "" { 92 return nil, errors.New("scheme is required for a full url on FindTodosURL") 93 } 94 if host == "" { 95 return nil, errors.New("host is required for a full url on FindTodosURL") 96 } 97 98 base, err := o.Build() 99 if err != nil { 100 return nil, err 101 } 102 103 base.Scheme = scheme 104 base.Host = host 105 return base, nil 106 } 107 108 // StringFull returns the string representation of a complete url 109 func (o *FindTodosURL) StringFull(scheme, host string) string { 110 return o.Must(o.BuildFull(scheme, host)).String() 111 }