-
Notifications
You must be signed in to change notification settings - Fork 0
/
multipart_serialization_writer_factory.go
35 lines (29 loc) · 1.26 KB
/
multipart_serialization_writer_factory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package multipartserialization
import (
"errors"
absser "github.com/microsoft/kiota-abstractions-go/serialization"
)
// MultipartSerializationWriterFactory implements SerializationWriterFactory for URI Multipart encoded.
type MultipartSerializationWriterFactory struct {
}
// NewMultipartSerializationWriterFactory creates a new instance of the MultipartSerializationWriterFactory.
func NewMultipartSerializationWriterFactory() *MultipartSerializationWriterFactory {
return &MultipartSerializationWriterFactory{}
}
// GetValidContentType returns the valid content type for the SerializationWriterFactoryRegistry
func (f *MultipartSerializationWriterFactory) GetValidContentType() (string, error) {
return "multipart/form-data", nil
}
// GetSerializationWriter returns the relevant SerializationWriter instance for the given content type
func (f *MultipartSerializationWriterFactory) GetSerializationWriter(contentType string) (absser.SerializationWriter, error) {
validType, err := f.GetValidContentType()
if err != nil {
return nil, err
} else if contentType == "" {
return nil, errors.New("contentType is empty")
} else if contentType != validType {
return nil, errors.New("contentType is not valid")
} else {
return NewMultipartSerializationWriter(), nil
}
}