37 lines
765 B
Go
37 lines
765 B
Go
|
package httpaccept
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
var _ error = &internalNotAcceptable{}
|
||
|
|
||
|
type internalNotAcceptable struct {
|
||
|
mediatypes []string
|
||
|
}
|
||
|
|
||
|
func (receiver internalNotAcceptable) Error() string {
|
||
|
var mediatypes []string = receiver.mediatypes
|
||
|
|
||
|
if len(mediatypes) < 1 {
|
||
|
return "httpaccept: none of the provided media-types are acceptable, because an empty list of media-types was provided"
|
||
|
}
|
||
|
|
||
|
var buffer strings.Builder
|
||
|
buffer.WriteString("httpaccept: none of the provided media-types are acceptable —")
|
||
|
for _, mediatype := range mediatypes {
|
||
|
fmt.Fprintf(&buffer, " %q", mediatype)
|
||
|
}
|
||
|
|
||
|
return buffer.String()
|
||
|
}
|
||
|
|
||
|
func (internalNotAcceptable) ClientError() {
|
||
|
// Nothing here.
|
||
|
}
|
||
|
|
||
|
func (internalNotAcceptable) NotAcceptable() {
|
||
|
// Nothing here.
|
||
|
}
|