Centralize remaining runtime constants and add precedence/default fallback coverage

This commit is contained in:
2026-05-05 11:01:44 -05:00
parent d82bcd0581
commit ddb4254124
5 changed files with 70 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import (
"crypto/sha256"
"errors"
"fmt"
"gitea.maximumdirect.net/eric/scriptorium/internal/defaults"
"gitea.maximumdirect.net/eric/scriptorium/internal/domain"
"mime"
"os"
@@ -67,7 +68,7 @@ func (r *inlineReader) Read(ctx context.Context, ref domain.ArtifactRef) (*domai
body := []byte(ref.Body)
return &domain.Artifact{
ContentType: "text/plain",
ContentType: defaults.ContentTypeTextPlain,
Body: body,
Size: int64(len(body)),
Hash: fmt.Sprintf("%x", sha256.Sum256(body)),
@@ -95,7 +96,7 @@ func (r *fileReader) Read(ctx context.Context, ref domain.ArtifactRef) (*domain.
contentType := mime.TypeByExtension(filepath.Ext(ref.URI))
if contentType == "" {
contentType = "text/plain" // Default
contentType = defaults.ContentTypeTextPlain
}
return &domain.Artifact{