fix: using tagged switch

This commit is contained in:
2025-07-22 18:52:26 +01:00
parent 4d0dcccf94
commit 1b816e512a

View File

@ -213,7 +213,8 @@ func main() {
// TODO: length checks on body // TODO: length checks on body
// TODO: extract this shit out // TODO: extract this shit out
image := make([]byte, 0) image := make([]byte, 0)
if contentType == "application/base64" { switch contentType {
case "application/base64":
decoder := base64.NewDecoder(base64.StdEncoding, r.Body) decoder := base64.NewDecoder(base64.StdEncoding, r.Body)
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
@ -229,7 +230,7 @@ func main() {
fmt.Println(decodedIamge) fmt.Println(decodedIamge)
image = buf.Bytes() image = buf.Bytes()
} else if contentType == "application/oclet-stream" || contentType == "image/png" { case "application/oclet-stream", "image/png":
bodyData, err := io.ReadAll(r.Body) bodyData, err := io.ReadAll(r.Body)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
@ -240,7 +241,7 @@ func main() {
// TODO: check headers // TODO: check headers
image = bodyData image = bodyData
} else { default:
log.Println("bad stuff?") log.Println("bad stuff?")
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, "Bruh, you need oclet stream or base64") fmt.Fprintf(w, "Bruh, you need oclet stream or base64")