github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/examples/auto-configure/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  	"github.com/go-openapi/swag"
    15  )
    16  
    17  // DestroyOneURL generates an URL for the destroy one operation
    18  type DestroyOneURL struct {
    19  	ID 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 *DestroyOneURL) WithBasePath(bp string) *DestroyOneURL {
    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 *DestroyOneURL) SetBasePath(bp string) {
    38  	o._basePath = bp
    39  }
    40  
    41  // Build a url path and query string
    42  func (o *DestroyOneURL) Build() (*url.URL, error) {
    43  	var _result url.URL
    44  
    45  	var _path = "/{id}"
    46  
    47  	id := swag.FormatInt64(o.ID)
    48  	if id != "" {
    49  		_path = strings.Replace(_path, "{id}", id, -1)
    50  	} else {
    51  		return nil, errors.New("id is required on DestroyOneURL")
    52  	}
    53  
    54  	_basePath := o._basePath
    55  	_result.Path = golangswaggerpaths.Join(_basePath, _path)
    56  
    57  	return &_result, nil
    58  }
    59  
    60  // Must is a helper function to panic when the url builder returns an error
    61  func (o *DestroyOneURL) Must(u *url.URL, err error) *url.URL {
    62  	if err != nil {
    63  		panic(err)
    64  	}
    65  	if u == nil {
    66  		panic("url can't be nil")
    67  	}
    68  	return u
    69  }
    70  
    71  // String returns the string representation of the path with query string
    72  func (o *DestroyOneURL) String() string {
    73  	return o.Must(o.Build()).String()
    74  }
    75  
    76  // BuildFull builds a full url with scheme, host, path and query string
    77  func (o *DestroyOneURL) BuildFull(scheme, host string) (*url.URL, error) {
    78  	if scheme == "" {
    79  		return nil, errors.New("scheme is required for a full url on DestroyOneURL")
    80  	}
    81  	if host == "" {
    82  		return nil, errors.New("host is required for a full url on DestroyOneURL")
    83  	}
    84  
    85  	base, err := o.Build()
    86  	if err != nil {
    87  		return nil, err
    88  	}
    89  
    90  	base.Scheme = scheme
    91  	base.Host = host
    92  	return base, nil
    93  }
    94  
    95  // StringFull returns the string representation of a complete url
    96  func (o *DestroyOneURL) StringFull(scheme, host string) string {
    97  	return o.Must(o.BuildFull(scheme, host)).String()
    98  }