mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 23:09:41 +02:00
* feat(api): add motd handler * feat(app): add the motd api layer * feat(motd): display motd and add the ability to dismiss information messages * style(home): relocate important message before info01 * feat(api): silently fail when an error occurs during motd retrieval
27 lines
612 B
Go
27 lines
612 B
Go
package motd
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/portainer/portainer"
|
|
"github.com/portainer/portainer/crypto"
|
|
"github.com/portainer/portainer/http/client"
|
|
"github.com/portainer/portainer/http/response"
|
|
)
|
|
|
|
type motdResponse struct {
|
|
Message string `json:"Message"`
|
|
Hash []byte `json:"Hash"`
|
|
}
|
|
|
|
func (handler *Handler) motd(w http.ResponseWriter, r *http.Request) {
|
|
|
|
motd, err := client.Get(portainer.MessageOfTheDayURL)
|
|
if err != nil {
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
hash := crypto.HashFromBytes(motd)
|
|
response.JSON(w, &motdResponse{Message: string(motd), Hash: hash})
|
|
}
|