Skip to content
Permalink
Browse files

Properly marshal imageType, resizingType and gravityType

  • Loading branch information...
DarthSim committed Oct 10, 2019
1 parent cc39450 commit 7c13bdad11884c8f38c1f4260343c336f33d30cb
Showing with 27 additions and 0 deletions.
  1. +9 −0 image_type.go
  2. +18 −0 processing_options.go
@@ -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

0 comments on commit 7c13bda

Please sign in to comment.
You can’t perform that action at this time.