uritemplates

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: BSD-3-Clause 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.Expand(values)
fmt.Printf(expanded)

Added by Joe-cli-http:

  • PartialExpand to support partially expanding a template

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 (u *URITemplate) Expand(value any) (string, error)

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

func (*URITemplate) Names

func (u *URITemplate) Names() []string

Names returns the names of all variables within the template.

func (*URITemplate) PartialExpand

func (u *URITemplate) PartialExpand(value any) (string, error)

PartialExpand expands a URI template with a set of values to produce a string, preserving any unknown parameters

func (URITemplate) String

func (u URITemplate) String() string

Jump to

Keyboard shortcuts

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