mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-09-16 09:36:18 +02:00
Properly marshal imageType, resizingType and gravityType
This commit is contained in:
@@ -78,6 +78,15 @@ func (it imageType) String() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (it imageType) MarshalJSON() ([]byte, error) {
|
||||
for k, v := range imageTypes {
|
||||
if v == it {
|
||||
return []byte(fmt.Sprintf("%q", k)), nil
|
||||
}
|
||||
}
|
||||
return []byte("null"), nil
|
||||
}
|
||||
|
||||
func (it imageType) Mime() string {
|
||||
if mime, ok := mimes[it]; ok {
|
||||
return mime
|
||||
|
@@ -152,6 +152,15 @@ func (gt gravityType) String() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (gt gravityType) MarshalJSON() ([]byte, error) {
|
||||
for k, v := range gravityTypes {
|
||||
if v == gt {
|
||||
return []byte(fmt.Sprintf("%q", k)), nil
|
||||
}
|
||||
}
|
||||
return []byte("null"), nil
|
||||
}
|
||||
|
||||
func (rt resizeType) String() string {
|
||||
for k, v := range resizeTypes {
|
||||
if v == rt {
|
||||
@@ -161,6 +170,15 @@ func (rt resizeType) String() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (rt resizeType) MarshalJSON() ([]byte, error) {
|
||||
for k, v := range resizeTypes {
|
||||
if v == rt {
|
||||
return []byte(fmt.Sprintf("%q", k)), nil
|
||||
}
|
||||
}
|
||||
return []byte("null"), nil
|
||||
}
|
||||
|
||||
var (
|
||||
_newProcessingOptions processingOptions
|
||||
newProcessingOptionsOnce sync.Once
|
||||
|
Reference in New Issue
Block a user