url

Function

ArgDescriptionType
schemeThe scheme to usestring
hostThe host componentstring
pathThe path componentstring
fragmentThe fragmentstring
parseA url to parsestring

Description

Construct a URL or parse one.

This function parses or constructs URLs. A URL may be constructed from scratch by providing all the components or it may be parsed from an existing URL.

The returned object is a golang URL and can be serialized again using its String method.

This function is important when constructing parameters for certain accessors which receive a URL. For example the zip accessor requires its file names to consist of URLs. The Zip accessor interprets the URL in the following way:

  • The scheme is the delegate accessor to use.
  • The path is the delegate accessor’s filename
  • The fragment is used by the zip accessor to retrieve the zip member itself.

In this case it is critical to properly escape each level - it is not possible in the general case to simply append strings. You need to use the url() function to build the proper url.

comments powered by Disqus