summaryrefslogtreecommitdiff
path: root/internal/accept/accept.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-08-18 13:40:20 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-08-18 13:40:20 +0200
commita3ccdd9f491c20771cfda343ebebd4b5d0ea6602 (patch)
treef0ad530dd072c55c6f46dfea23af993fb31333d4 /internal/accept/accept.go
parent5d17264c8ab8042042162f3b968557aabc4976b3 (diff)
downloadgo-gg-a3ccdd9f491c20771cfda343ebebd4b5d0ea6602.tar.gz
test coverage for microprom
Diffstat (limited to 'internal/accept/accept.go')
-rw-r--r--internal/accept/accept.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/internal/accept/accept.go b/internal/accept/accept.go
index 5ed6e66..c23905a 100644
--- a/internal/accept/accept.go
+++ b/internal/accept/accept.go
@@ -103,6 +103,11 @@ func (h Header) Negotiate(mediaTypes ...string) Option[string] {
return None[string]()
}
+ // if nothing was offered, we default to our own preferred option
+ if len(h.options) == 0 {
+ return Some(offers[0].OriginalValue)
+ }
+
// NOTE: ParseHeader() sorts options by descending weight, so the first match wins.
for _, opt := range h.options {
MEDIATYPE:
@@ -128,5 +133,5 @@ func (h Header) Negotiate(mediaTypes ...string) Option[string] {
}
}
- return Some(offers[0].OriginalValue)
+ return None[string]()
}