draft

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDraftNotMappable             = errors.New("draft content is invalid for mapping")
	ErrDraftNotValid                = errors.New("draft content is invalid")
	ErrDraftContentTypeNotSupported = errors.New("draft content-type is invalid")
)

Functions

func BuildContentTypeMapping added in v1.2.1

func BuildContentTypeMapping(validatorConfig *config.Config, httpClient *http.Client, log *logger.UPPLogger) map[string]ContentValidator

Types

type ContentAPI

type ContentAPI interface {
	FetchDraftContent(ctx context.Context, uuid string) (content []byte, err error)
	FetchValidatedContent(ctx context.Context, body io.Reader, contentUUID string, contentType string, log *logger.UPPLogger) ([]byte, error)
	endpointessentials.Endpoint
}

ContentApi for accessing to draft-content-api endpoint

func NewContentAPI

func NewContentAPI(endpoint string, healthEndpoint string, httpClient *http.Client, healthHTTPClient *http.Client, resolver ContentValidatorResolver) (contentAPI ContentAPI, err error)

type ContentValidator added in v1.2.1

type ContentValidator interface {
	Validate(ctx context.Context, contentUUID string, nativeBody io.Reader, contentType string, log *logger.UPPLogger) (io.ReadCloser, error)
	GTG() error
	Endpoint() string
}

func NewDraftContentValidatorService added in v1.2.1

func NewDraftContentValidatorService(endpoint string, httpClient *http.Client) ContentValidator

type ContentValidatorResolver added in v1.2.1

type ContentValidatorResolver interface {
	// ValidatorForContentType Resolves and returns a ContentValidator implementation if present.
	ValidatorForContentType(contentType string) (ContentValidator, error)
}

ContentValidatorResolver manages the validators available for a given originId/content-type pair.

func NewContentValidatorResolver added in v1.2.1

func NewContentValidatorResolver(contentTypeToValidator map[string]ContentValidator) ContentValidatorResolver

NewContentValidatorResolver returns a ContentValidatorResolver implementation

type MockDraftContentAPI added in v1.2.1

type MockDraftContentAPI struct {
	mock.Mock
}

func (*MockDraftContentAPI) Endpoint added in v1.2.1

func (_md *MockDraftContentAPI) Endpoint() string

func (*MockDraftContentAPI) FetchDraftContent added in v1.2.1

func (_md *MockDraftContentAPI) FetchDraftContent(ctx context.Context, uuid string) (content []byte, err error)

func (*MockDraftContentAPI) FetchValidatedContent added in v1.2.1

func (_md *MockDraftContentAPI) FetchValidatedContent(ctx context.Context, body io.Reader, contentUUID string, contentType string, log *logger.UPPLogger) ([]byte, error)

func (*MockDraftContentAPI) IsGTG added in v1.2.1

func (_md *MockDraftContentAPI) IsGTG(ctx context.Context) (string, error)

func (*MockDraftContentAPI) IsValid added in v1.2.1

func (_md *MockDraftContentAPI) IsValid() error

type MockValidator added in v1.2.1

type MockValidator struct {
	mock.Mock
}

func (*MockValidator) Endpoint added in v1.2.1

func (_mv *MockValidator) Endpoint() string

func (*MockValidator) GTG added in v1.2.1

func (_mv *MockValidator) GTG() error

func (*MockValidator) Validate added in v1.2.1

func (_mv *MockValidator) Validate(ctx context.Context, contentUUID string, nativeBody io.Reader, contentType string, log *logger.UPPLogger) (io.ReadCloser, error)

type MockValidatorResolver added in v1.2.1

type MockValidatorResolver struct {
	mock.Mock
}

func (*MockValidatorResolver) ValidatorForContentType added in v1.2.1

func (_mr *MockValidatorResolver) ValidatorForContentType(contentType string) (ContentValidator, error)

type ValidatorError added in v1.2.1

type ValidatorError struct {
	// contains filtered or unexported fields
}

func (ValidatorError) Error added in v1.2.1

func (e ValidatorError) Error() string

func (ValidatorError) StatusCode added in v1.2.1

func (e ValidatorError) StatusCode() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL