github.com/nsqio/nsq@v1.3.0/internal/http_api/topic_channel_args.go (about) 1 package http_api 2 3 import ( 4 "errors" 5 6 "github.com/nsqio/nsq/internal/protocol" 7 ) 8 9 type getter interface { 10 Get(key string) (string, error) 11 } 12 13 func GetTopicChannelArgs(rp getter) (string, string, error) { 14 topicName, err := rp.Get("topic") 15 if err != nil { 16 return "", "", errors.New("MISSING_ARG_TOPIC") 17 } 18 19 if !protocol.IsValidTopicName(topicName) { 20 return "", "", errors.New("INVALID_ARG_TOPIC") 21 } 22 23 channelName, err := rp.Get("channel") 24 if err != nil { 25 return "", "", errors.New("MISSING_ARG_CHANNEL") 26 } 27 28 if !protocol.IsValidChannelName(channelName) { 29 return "", "", errors.New("INVALID_ARG_CHANNEL") 30 } 31 32 return topicName, channelName, nil 33 }