uritemplates

package
v1.348.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: Apache-2.0, MIT Imports: 7 Imported by: 0

Documentation

Overview

Package uritemplates is a level 4 implementation of RFC 6570 (URI Template, http://tools.ietf.org/html/rfc6570).

To use uritemplates, parse a template string and expand it with a value map:

template, _ := uritemplates.Parse("https://api.github.com/repos{/user,repo}")
values := make(map[string]interface{})
values["user"] = "jtacoma"
values["repo"] = "uritemplates"
expanded, _ := template.ExpandString(values)
fmt.Printf(expanded)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(path string, values Values) (string, error)

Types

type Template

type Template struct {
	// contains filtered or unexported fields
}

A Template is a parsed representation of a URI template.

func Parse

func Parse(rawtemplate string) (template *Template, err error)

Parse parses a URI template string into a Template object.

func (*Template) Expand

func (self *Template) Expand(value interface{}) (string, error)

Expand expands a URI template with a set of values to produce a string.

type Values

type Values map[string]interface{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL