refactoring and introduction of logrus logging

This commit is contained in:
2025-09-14 16:10:29 -06:00
parent ae3c9ca748
commit cc8c12e24d
5 changed files with 66 additions and 2 deletions
+5 -2
View File
@@ -19,6 +19,10 @@ import (
//go:embed static_images/*
var static_images embed.FS
func mimeTypeFromFilename(filename string) string {
return mime.TypeByExtension(filename[strings.LastIndex(filename, "."):])
}
func AmServeImage(ctxt AmContext) (string, any, error) {
components := strings.SplitAfter(ctxt.URLPath(), "/")
var err error = nil
@@ -26,8 +30,7 @@ func AmServeImage(ctxt AmContext) (string, any, error) {
var b []byte
b, err = static_images.ReadFile(fmt.Sprintf("static_images/%s", components[3]))
if err == nil {
mtype := mime.TypeByExtension(components[3][strings.LastIndex(components[3], "."):])
ctxt.SetOutputType(mtype)
ctxt.SetOutputType(mimeTypeFromFilename(components[3]))
return "bytes", b, nil
}
}