mirror of
https://github.com/Cernobor/oko-server.git
synced 2025-02-24 08:27:17 +00:00
* errors put into separate package * added table to store feature photos * added API endpoints for serving photos * POST /data extended to accept photos using a multipart/form-data body
35 lines
613 B
Go
35 lines
613 B
Go
package server
|
|
|
|
import (
|
|
"cernobor.cz/oko-server/models"
|
|
)
|
|
|
|
func ptrInt(x int) *int {
|
|
return &x
|
|
}
|
|
|
|
func ptrInt64(x int64) *int64 {
|
|
return &x
|
|
}
|
|
|
|
func ptrString(x string) *string {
|
|
return &x
|
|
}
|
|
|
|
var contentTypes map[string]struct{} = map[string]struct{}{"image/jpeg": {}, "image/png": {}}
|
|
|
|
func checkImageContentType(contentType string) bool {
|
|
_, ok := contentTypes[contentType]
|
|
return ok
|
|
}
|
|
|
|
func isUniqueFeatureID(features []models.Feature) bool {
|
|
ids := make(map[models.FeatureID]struct{}, len(features))
|
|
for _, f := range features {
|
|
if _, pres := ids[f.ID]; pres {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|