PLT-1649: add response_url support for custom slash commands (#6739)

* add response_url support for custom slash commands

* pr suggestions

* pr update / suggestion

* test fix
Этот коммит содержится в:
Chris
2017-08-16 07:17:57 -05:00
коммит произвёл Joram Wilander
родитель 5cd45c9394
Коммит b122381e87
18 изменённых файлов: 562 добавлений и 11 удалений

Просмотреть файл

@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
"io/ioutil"
)
const (
@@ -31,6 +32,22 @@ func (o *CommandResponse) ToJson() string {
}
}
func CommandResponseFromHTTPBody(contentType string, body io.Reader) *CommandResponse {
if contentType == "application/json" {
return CommandResponseFromJson(body)
}
if b, err := ioutil.ReadAll(body); err == nil {
return CommandResponseFromPlainText(string(b))
}
return nil
}
func CommandResponseFromPlainText(text string) *CommandResponse {
return &CommandResponse{
Text: text,
}
}
func CommandResponseFromJson(data io.Reader) *CommandResponse {
decoder := json.NewDecoder(data)
var o CommandResponse