summaryrefslogtreecommitdiffstats
path: root/common.go
diff options
context:
space:
mode:
Diffstat (limited to 'common.go')
-rw-r--r--common.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/common.go b/common.go
index e6173b0..310da86 100644
--- a/common.go
+++ b/common.go
@@ -139,3 +139,27 @@ func setTime(m *Message, param string, t time.Time) {
m.SetParam(param, t.UTC().Format(time.RFC3339))
}
}
+
+func getSelect(m *Message, param string) (string, string, error) {
+ s := m.Param(param)
+ if s == "" {
+ return "", "", nil
+ }
+ ss := strings.SplitN(s, ":", 2)
+ if len(ss) != 2 || ss[0] == "" {
+ return "", "", ErrorInvalid{"invalid parameter: " + param + " is not a valid selector"}
+ }
+ return ss[0], ss[1], nil
+}
+
+func setSelect(m *Message, param string, selector, query string) error {
+ if strings.ContainsRune(selector, ':') {
+ return ErrorInvalid{"invalid parameter: " + param + " is not a valid selector name"}
+ }
+ if selector == "" {
+ m.SetParam(param, "")
+ } else {
+ m.SetParam(param, selector+":"+query)
+ }
+ return nil
+}