+htc,java #18600 Add missing convenience ContentTypes class

This commit is contained in:
Konrad Malawski 2015-09-29 20:58:47 +02:00
parent 239b4ca268
commit 2f2e07666e
4 changed files with 25 additions and 2 deletions

View file

@ -6,6 +6,7 @@ package docs.http.javadsl.server;
//#high-level-server-example
import akka.actor.ActorSystem;
import akka.http.javadsl.model.ContentTypes;
import akka.http.javadsl.model.MediaTypes;
import akka.http.javadsl.server.*;
import akka.http.javadsl.server.values.Parameters;
@ -50,7 +51,7 @@ public class HighLevelServerExample extends HttpApp {
// matches the empty path
pathSingleSlash().route(
// return a constant string with a certain content type
complete(MediaTypes.TEXT_HTML.toContentType(),
complete(ContentTypes.TEXT_HTML,
"<html><body>Hello world!</body></html>")
),
path("ping").route(

View file

@ -72,7 +72,7 @@ public class HttpServerExampleDocTest {
if (uri.path().equals("/"))
return
HttpResponse.create()
.withEntity(MediaTypes.TEXT_HTML.toContentType(),
.withEntity(ContentTypes.TEXT_HTML,
"<html><body>Hello world!</body></html>");
else if (uri.path().equals("/hello")) {
String name = Util.getOrElse(uri.parameter("name"), "Mister X");