2018-08-21 18:40:42 +00:00
|
|
|
package motd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2018-09-10 10:01:38 +00:00
|
|
|
"github.com/portainer/libhttp/response"
|
2018-08-21 18:40:42 +00:00
|
|
|
"github.com/portainer/portainer"
|
|
|
|
"github.com/portainer/portainer/crypto"
|
|
|
|
"github.com/portainer/portainer/http/client"
|
|
|
|
)
|
|
|
|
|
|
|
|
type motdResponse struct {
|
|
|
|
Message string `json:"Message"`
|
|
|
|
Hash []byte `json:"Hash"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (handler *Handler) motd(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
2018-09-24 00:09:12 +00:00
|
|
|
motd, err := client.Get(portainer.MessageOfTheDayURL, 0)
|
2018-08-21 18:40:42 +00:00
|
|
|
if err != nil {
|
|
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
hash := crypto.HashFromBytes(motd)
|
|
|
|
response.JSON(w, &motdResponse{Message: string(motd), Hash: hash})
|
|
|
|
}
|