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