-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Configurable MIME type for mustache template encoding on set processor #65314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ public final class ConfigurationUtils { | |
|
||
public static final String TAG_KEY = "tag"; | ||
public static final String DESCRIPTION_KEY = "description"; | ||
public static final String[] VALID_MIME_TYPES = {"application/json", "text/plain", "application/x-www-form-urlencoded"}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want the se hardcoded? What if someone specifies There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that unifying this set of options would be good. I can do that after you merge that PR. I don't believe that we want to allow the specification of a particular character set for the use case of the ingest processor, though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
private ConfigurationUtils() { | ||
} | ||
|
@@ -305,6 +306,18 @@ public static Object readObject(String processorType, String processorTag, Map<S | |
return value; | ||
} | ||
|
||
public static String readMimeTypeProperty(String processorType, String processorTag, Map<String, Object> configuration, | ||
String propertyName, String defaultValue) { | ||
String mimeType = readStringProperty(processorType, processorTag, configuration, propertyName, defaultValue); | ||
|
||
if (Arrays.asList(VALID_MIME_TYPES).contains(mimeType) == false) { | ||
throw newConfigurationException(processorType, processorTag, propertyName, | ||
"property does not contain a supported MIME type [" + mimeType + "]"); | ||
} | ||
|
||
return mimeType; | ||
} | ||
|
||
public static ElasticsearchException newConfigurationException(String processorType, String processorTag, | ||
String propertyName, String reason) { | ||
String msg; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we sure we want
mime_type
as a name here? I thought mime was replace withmedia_type
but wouldn't
content_type
be more consistent with what we have in mustache templating engine?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or we could consider to rename the content_type to media_type (in mustache template engine)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to rename to whatever is most appropriate. I went with
mime_type
because that is what was used inCustomMustacheFactory
but I would agree thatmedia_type
or possiblycontent_type
would be better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to follow up with a change to
media_type
to be more correct.