-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove dependency on pekko-http-jackson (#93)
* remove dependency on pekko-http-jackson * Update NOTICE * Update Jackson.java
- Loading branch information
Showing
4 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
pekko-http-jackson/src/main/java/com/github/pjfanning/pekkohttpjackson/Jackson.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters