Skip to content

Commit

Permalink
remove dependency on pekko-http-jackson (#93)
Browse files Browse the repository at this point in the history
* remove dependency on pekko-http-jackson

* Update NOTICE

* Update Jackson.java
  • Loading branch information
pjfanning authored Mar 2, 2025
1 parent 68015fc commit dd6292a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 3 deletions.
14 changes: 14 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
Copyright 2015 Heiko Seeberger

Includes code from the following projects:

Apache Pekko HTTP
Copyright 2022-2025 The Apache Software Foundation

This product includes software developed at
The Apache Software Foundation (https://www.apache.org/).

This product contains significant parts that were originally based on software from Lightbend (Akka <https://akka.io/>).
Copyright (C) 2009-2022 Lightbend Inc. <https://www.lightbend.com>

Apache Pekko-HTTP is derived from Akka-HTTP 10.2.x, the last version that was distributed under the
Apache License, Version 2.0 License.
2 changes: 0 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ lazy val `pekko-http-jackson` =
.settings(
libraryDependencies ++= Seq(
library.pekkoHttp,
library.pekkoHttpJacksonJava,
library.jacksonModuleScala,
library.pekkoStream % Provided,
library.scalaTest % Test,
Expand Down Expand Up @@ -238,7 +237,6 @@ lazy val library =
}
// format: off
val pekkoHttp = "org.apache.pekko" %% "pekko-http" % Version.pekkoHttp
val pekkoHttpJacksonJava = "org.apache.pekko" %% "pekko-http-jackson" % Version.pekkoHttp
val pekkoStream = "org.apache.pekko" %% "pekko-stream" % Version.pekko
val argonaut = "io.github.argonaut-io" %% "argonaut" % Version.argonaut
val avro4sJson = "com.sksamuel.avro4s" %% "avro4s-json" % Version.avro4s
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* license agreements; and to You under the Apache License, version 2.0:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* This file is part of the Apache Pekko project, which was derived from Akka.
*/

/*
* Copyright (C) 2009-2022 Lightbend Inc. <https://www.lightbend.com>
*/

package com.github.pjfanning.pekkohttpjackson;

import org.apache.pekko.http.javadsl.model.MediaTypes;
import org.apache.pekko.http.javadsl.model.RequestEntity;
import org.apache.pekko.http.javadsl.marshalling.Marshaller;

import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.databind.ObjectMapper;

final class Jackson {

static <T> Marshaller<T, RequestEntity> marshaller(ObjectMapper mapper) {
return Marshaller.wrapEntity(
u -> toJSON(mapper, u), Marshaller.stringToEntity(), MediaTypes.APPLICATION_JSON);
}

private static String toJSON(ObjectMapper mapper, Object object) {
try {
return mapper.writeValueAsString(object);
} catch (JacksonException e) {
throw new IllegalArgumentException("Cannot marshal to JSON: " + object, e);
}
}

private Jackson() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.scala.{ ClassTagExtensions, JavaTypeable }
import com.typesafe.config.{ Config, ConfigFactory }
import org.apache.pekko.http.javadsl.common.JsonEntityStreamingSupport
import org.apache.pekko.http.javadsl.marshallers.jackson.Jackson
import org.apache.pekko.http.scaladsl.common.EntityStreamingSupport
import org.apache.pekko.http.scaladsl.marshalling._
import org.apache.pekko.http.scaladsl.model.{
Expand Down

0 comments on commit dd6292a

Please sign in to comment.