-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
95 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (C) 2016 Kohei YOSHIDA. All rights reserved. | ||
// | ||
// This program is free software; you can redistribute it and/or | ||
// modify it under the terms of The BSD 3-Clause License | ||
// that can be found in the LICENSE file. | ||
|
||
package uritemplate | ||
|
||
type Values map[string]Value | ||
|
||
func (v Values) Set(name string, value Value) { | ||
v[name] = value // TODO(yosida95): canonicalize pct-encoded in the name | ||
} | ||
|
||
func (v Values) Get(name string) Value { | ||
if v == nil { | ||
return nil | ||
} | ||
return v[name] // TODO(yosida95): canonicalize pct-encoded in the name | ||
} | ||
|
||
type Value interface { | ||
} | ||
|
||
// String returns Value that represents string. | ||
func String(v string) Value { | ||
return valueString(v) | ||
} | ||
|
||
type valueString string | ||
|
||
// List returns Value that represents list. | ||
func List(v ...string) Value { | ||
return valueList(v) | ||
} | ||
|
||
type valueList []string | ||
|
||
// KV returns Value that represents associative list. | ||
// KV panics if len(kv) is not even. | ||
func KV(kv ...string) Value { | ||
if len(kv)%2 != 0 { | ||
panic("uritemplate.go: count of the kv must be even number") | ||
} | ||
return valueKV(kv) | ||
} | ||
|
||
type valueKV []string |