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

Get string representation of javadsl Content and Media Type #630

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void customMediaTypes() throws ExecutionException, InterruptedException {
extractRequest(
req ->
complete(
req.entity().getContentType().toString()
req.entity().getContentType().value()
+ " = "
+ req.entity().getContentType().getClass()));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.pekko.http.javadsl.model.ContentType.value")
ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.pekko.http.javadsl.model.MediaType.value")
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package org.apache.pekko.http.javadsl.model

import org.apache.pekko.annotation.DoNotInherit

import java.util.Optional

// Has to be defined in Scala even though it's JavaDSL because of:
Expand Down Expand Up @@ -45,6 +47,7 @@ object ContentType {
*
* See [[ContentTypes]] for convenience access to often used values.
*/
@DoNotInherit
trait ContentType {

/**
Expand All @@ -61,4 +64,10 @@ trait ContentType {
* Returns the charset if this ContentType is non-binary.
*/
def getCharsetOption: Optional[HttpCharset]

/**
* Returns the string representation of this ContentType
* @since 1.2.0
*/
def value: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package org.apache.pekko.http.javadsl.model

import org.apache.pekko.annotation.DoNotInherit

/**
* Represents an Http media-type. A media-type consists of a main-type and a sub-type.
*
Expand Down Expand Up @@ -65,6 +67,7 @@ object MediaType {
}
}

@DoNotInherit
trait MediaType {

/**
Expand Down Expand Up @@ -110,4 +113,10 @@ trait MediaType {
* Creates a media-range from this media-type with a given qValue.
*/
def toRange(qValue: Float): MediaRange

/**
* Returns the string representation of this MediaType
* @since 1.2.0
*/
def value: String
}
Loading