1
0
mirror of https://github.com/lus/pasty.git synced 2023-08-10 21:13:09 +03:00
pasty/internal/web/request_accept.go
2023-06-17 18:38:58 +02:00

15 lines
367 B
Go

package web
import "net/http"
func accept(writer http.ResponseWriter, request *http.Request, contentTypes ...string) bool {
contentType := request.Header.Get("Content-Type")
for _, accepted := range contentTypes {
if contentType == accepted {
return true
}
}
writeString(writer, http.StatusUnsupportedMediaType, "unsupported media type")
return false
}