github.com/djarvur/go-swagger@v0.18.0/examples/todo-list/restapi/operations/todos/destroy_one_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 "strings" 13 ) 14 15 // DestroyOneURL generates an URL for the destroy one operation 16 type DestroyOneURL struct { 17 ID string 18 19 _basePath string 20 // avoid unkeyed usage 21 _ struct{} 22 } 23 24 // WithBasePath sets the base path for this url builder, only required when it's different from the 25 // base path specified in the swagger spec. 26 // When the value of the base path is an empty string 27 func (o *DestroyOneURL) WithBasePath(bp string) *DestroyOneURL { 28 o.SetBasePath(bp) 29 return o 30 } 31 32 // SetBasePath sets the base path for this url builder, only required when it's different from the 33 // base path specified in the swagger spec. 34 // When the value of the base path is an empty string 35 func (o *DestroyOneURL) SetBasePath(bp string) { 36 o._basePath = bp 37 } 38 39 // Build a url path and query string 40 func (o *DestroyOneURL) Build() (*url.URL, error) { 41 var _result url.URL 42 43 var _path = "/{id}" 44 45 id := o.ID 46 if id != "" { 47 _path = strings.Replace(_path, "{id}", id, -1) 48 } else { 49 return nil, errors.New("ID is required on DestroyOneURL") 50 } 51 52 _basePath := o._basePath 53 _result.Path = golangswaggerpaths.Join(_basePath, _path) 54 55 return &_result, nil 56 } 57 58 // Must is a helper function to panic when the url builder returns an error 59 func (o *DestroyOneURL) Must(u *url.URL, err error) *url.URL { 60 if err != nil { 61 panic(err) 62 } 63 if u == nil { 64 panic("url can't be nil") 65 } 66 return u 67 } 68 69 // String returns the string representation of the path with query string 70 func (o *DestroyOneURL) String() string { 71 return o.Must(o.Build()).String() 72 } 73 74 // BuildFull builds a full url with scheme, host, path and query string 75 func (o *DestroyOneURL) BuildFull(scheme, host string) (*url.URL, error) { 76 if scheme == "" { 77 return nil, errors.New("scheme is required for a full url on DestroyOneURL") 78 } 79 if host == "" { 80 return nil, errors.New("host is required for a full url on DestroyOneURL") 81 } 82 83 base, err := o.Build() 84 if err != nil { 85 return nil, err 86 } 87 88 base.Scheme = scheme 89 base.Host = host 90 return base, nil 91 } 92 93 // StringFull returns the string representation of a complete url 94 func (o *DestroyOneURL) StringFull(scheme, host string) string { 95 return o.Must(o.BuildFull(scheme, host)).String() 96 }