utils.go raw

   1  // Copyright 2016 The Go Authors. All rights reserved.
   2  // Use of this source code is governed by a BSD-style
   3  // license that can be found in the LICENSE file.
   4  
   5  package uritemplates
   6  
   7  // Expand parses then expands a URI template with a set of values to produce
   8  // the resultant URI. Two forms of the result are returned: one with all the
   9  // elements escaped, and one with the elements unescaped.
  10  func Expand(path string, values map[string]string) (escaped, unescaped string, err error) {
  11  	template, err := parse(path)
  12  	if err != nil {
  13  		return "", "", err
  14  	}
  15  	escaped, unescaped = template.Expand(values)
  16  	return escaped, unescaped, nil
  17  }
  18