You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
829 B
32 lines
829 B
package controllers |
|
|
|
import ( |
|
"encoding/json" |
|
"net/http" |
|
"os" |
|
"strings" |
|
|
|
"github.com/owncast/owncast/config" |
|
"github.com/owncast/owncast/core/data" |
|
"github.com/owncast/owncast/router/middleware" |
|
) |
|
|
|
// GetCustomEmojiList returns a list of emoji via the API. |
|
func GetCustomEmojiList(w http.ResponseWriter, r *http.Request) { |
|
emojiList := data.GetEmojiList() |
|
middleware.SetCachingHeaders(w, r) |
|
|
|
if err := json.NewEncoder(w).Encode(emojiList); err != nil { |
|
InternalErrorHandler(w, err) |
|
} |
|
} |
|
|
|
// GetCustomEmojiImage returns a single emoji image. |
|
func GetCustomEmojiImage(w http.ResponseWriter, r *http.Request) { |
|
path := strings.TrimPrefix(r.URL.Path, "/img/emoji/") |
|
r.URL.Path = path |
|
|
|
emojiFS := os.DirFS(config.CustomEmojiPath) |
|
middleware.SetCachingHeaders(w, r) |
|
http.FileServer(http.FS(emojiFS)).ServeHTTP(w, r) |
|
}
|
|
|