oko-server/server/utils.go
zegkljan 5deff38890 refactoring, support for storing feature photos
* 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
2022-01-30 01:34:38 +01:00

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
}