Skip to content
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

RSocket Metadata Mimetype "text/plain" and "application/json" support #23157

Closed
linux-china opened this issue Jun 19, 2019 · 1 comment
Closed
Assignees
Labels
in: messaging Issues in messaging modules (jms, messaging) type: enhancement A general enhancement
Milestone

Comments

@linux-china
Copy link

Now RSocket adopts "message/x.rsocket.composite-metadata.v0" and "message/x.rsocket.routing.v0" as metadata MimeType. Please consider add "text/plain" as metadata Mime type, some cases, the text just as route key. If possible, could "application/json" be added as metadata Mime type and routing key is "routing" field like following:

{
  "routing": "chat_room",
  ....
}

Both "text/plain" and "application/json" are friendly and easy for Javascript in browser.

https://github.com/spring-projects/spring-framework/blob/master/spring-messaging/src/main/java/org/springframework/messaging/rsocket/MessagingRSocket.java

private String getDestination(Payload payload) {
		if (this.metadataMimeType.equals(DefaultRSocketRequester.COMPOSITE_METADATA)) {
			CompositeMetadata metadata = new CompositeMetadata(payload.metadata(), false);
			for (CompositeMetadata.Entry entry : metadata) {
				String mimeType = entry.getMimeType();
				if (DefaultRSocketRequester.ROUTING.toString().equals(mimeType)) {
					return entry.getContent().toString(StandardCharsets.UTF_8);
				}
			}
			return "";
		}
		else if (this.metadataMimeType.equals(DefaultRSocketRequester.ROUTING)) {
			return payload.getMetadataUtf8();
		}
		// Should not happen (given constructor assertions)
		throw new IllegalArgumentException("Unexpected metadataMimeType");
	}
@linux-china linux-china changed the title RSocket Metadata Mimetype text/plain support RSocket Metadata Mimetype "text/plain" and "application/json" support Jun 19, 2019
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 19, 2019
@rstoyanchev rstoyanchev added in: messaging Issues in messaging modules (jms, messaging) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 20, 2019
@rstoyanchev rstoyanchev added this to the 5.2 RC1 milestone Jun 20, 2019
@rstoyanchev
Copy link
Contributor

Thanks for the feedback. We'll try and make this more flexible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: messaging Issues in messaging modules (jms, messaging) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants