uritemplates

package
v2.3.3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: Apache-2.0, BSD-3-Clause Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.Expand(values)
fmt.Printf(expanded)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UriTemplate

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

A UriTemplate is a parsed representation of a URI template.

func Parse

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

Parse parses a URI template string into a UriTemplate object.

func (*UriTemplate) Expand

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

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

func (*UriTemplate) Names

func (self *UriTemplate) Names() []string

Names returns the names of all variables within the template.

func (UriTemplate) String

func (t UriTemplate) String() string

Jump to

Keyboard shortcuts

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