making the /generic/ endpoint respond with a message containing the response from Matrix.

This commit is contained in:
Matt Burchett 2021-02-04 01:26:46 -06:00
parent 1242858d84
commit 105657fc4b
2 changed files with 4 additions and 5 deletions

View File

@ -24,9 +24,9 @@ func Handle(cfg config.Config) http.HandlerFunc {
log.Error().Err(err).Msg("An error has occurred") log.Error().Err(err).Msg("An error has occurred")
} }
matrix.PublishText(cfg, vars, reqBody, token) resp := matrix.PublishText(cfg, vars, reqBody, token)
router.Respond(w, 200, nil) router.Respond(w, 200, resp)
} }
} }

View File

@ -61,7 +61,7 @@ func GetToken(cfg config.Config, vars map[string]string) string {
} }
// PublishText will publish the data to Matrix using the specified vars. // PublishText will publish the data to Matrix using the specified vars.
func PublishText(cfg config.Config, vars map[string]string, data []byte, token string) { func PublishText(cfg config.Config, vars map[string]string, data []byte, token string) []byte {
matrixPublish := struct { matrixPublish := struct {
MsgType string `json:"msgtype"` MsgType string `json:"msgtype"`
Body string `json:"body"` Body string `json:"body"`
@ -89,8 +89,7 @@ func PublishText(cfg config.Config, vars map[string]string, data []byte, token s
} }
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
defer resp.Body.Close() defer resp.Body.Close()
return body
} }