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

Document how to use Protobuf (or something else) as a MediaType #16548

Closed
aiyanbo opened this issue Dec 16, 2014 · 6 comments
Closed

Document how to use Protobuf (or something else) as a MediaType #16548

aiyanbo opened this issue Dec 16, 2014 · 6 comments
Labels
help wanted Issues that the core team will likely not have time to work on t:docs t:http
Milestone

Comments

@aiyanbo
Copy link

aiyanbo commented Dec 16, 2014

We used Protobuf encoding objects on my project. I marked data format as a MediaType, like this:

Content-Type: application/x-protobuf
@aiyanbo aiyanbo changed the title Support Protobuf as a MediaType akka-http: Support Protobuf as a MediaType Dec 16, 2014
@He-Pin
Copy link
Member

He-Pin commented Dec 16, 2014

#16523

@rkuhn
Copy link
Contributor

rkuhn commented Jan 20, 2015

This is already possible within the marshaling infrastructure, so this ticket should be regarded as a request to document how that works.

@rkuhn rkuhn added the 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted label Jan 20, 2015
@rkuhn rkuhn changed the title akka-http: Support Protobuf as a MediaType akka-http: Document how to use Protobuf (or something else) as a MediaType Jan 20, 2015
@sirthias sirthias changed the title akka-http: Document how to use Protobuf (or something else) as a MediaType Document how to use Protobuf (or something else) as a MediaType Feb 11, 2015
@kostya-sh
Copy link

Documentation with examples will certainly be very useful.

As a relative beginner with scala and akka I find it very hard to figure out how to set response content type in the following example:

complete {
   """{"a": 1}"""
} 

How to tell akka-http to set content type to application/json here?

@sirthias
Copy link
Contributor

@kostya-sh The server-side routing DSL provided by akka-http is very similarly to the one from spray.
You might want to check out this chapter from the spray docs for some info on how marshalling works:
http://spray.io/documentation/1.2.2/spray-httpx/marshalling/

@kostya-sh
Copy link

@sirthias Thank you for the link to the docs.

I figured out that I can do something like

complete {
    // do not import other implicit marshallers!
    implicit val marshaller = PredefinedToEntityMarshallers.stringMarshaller(MediaTypes.`application/json`)
    """{"a": 1}"""
}

to implement my requirement.

To be honest this solution looks a bit ugly to me and I guess there might be a better way to do it. This brings us back to the point of docs (with examples!).

@rkuhn rkuhn modified the milestone: http-1.x Oct 20, 2015
@rkuhn rkuhn added the help wanted Issues that the core team will likely not have time to work on label Oct 20, 2015
@ktoso ktoso modified the milestones: http-2.0, http-backlog Dec 21, 2015
@rkuhn rkuhn removed the 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted label Mar 9, 2016
@ktoso ktoso added the 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted label Apr 4, 2016
@ktoso ktoso removed the 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted label Sep 8, 2016
@ktoso
Copy link
Member

ktoso commented Sep 9, 2016

Ticket moved to github.com/akka/akka-http
Rationale for the move discussed here: akka/akka-meta#27

If you are interested in contributing or tracking this issue, please comment in akka-http instead from now on :-)

@ktoso ktoso closed this as completed Sep 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that the core team will likely not have time to work on t:docs t:http
Projects
None yet
Development

No branches or pull requests

7 participants