Merge pull request 'Enable JSON output.' (#5) from feature/enable-json into master
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: java/labyrinth-server#5
This commit is contained in:
Manuel Friedli 2023-04-14 01:39:41 +02:00
commit 7937f12508
2 changed files with 14 additions and 1 deletions

View file

@ -19,7 +19,7 @@
<java.target.version>17</java.target.version>
<jetbrains-annotations.version>24.0.1</jetbrains-annotations.version>
<junit-jupiter.version>5.9.2</junit-jupiter.version>
<labyrinth-generator.version>0.0.5</labyrinth-generator.version>
<labyrinth-generator.version>0.0.6</labyrinth-generator.version>
<logback.version>1.4.6</logback.version>
<lombok.version>1.18.26</lombok.version>
<slf4j.version>2.0.7</slf4j.version>

View file

@ -2,6 +2,7 @@ package ch.fritteli.labyrinth.server;
import ch.fritteli.labyrinth.generator.model.Labyrinth;
import ch.fritteli.labyrinth.generator.renderer.html.HTMLRenderer;
import ch.fritteli.labyrinth.generator.renderer.json.JsonRenderer;
import ch.fritteli.labyrinth.generator.renderer.pdf.PDFRenderer;
import ch.fritteli.labyrinth.generator.renderer.text.TextRenderer;
import ch.fritteli.labyrinth.generator.serialization.SerializerDeserializer;
@ -28,6 +29,18 @@ public enum OutputType {
false,
"h",
"html"),
JSON("application/json",
"json",
labyrinth -> JsonRenderer.newInstance().render(labyrinth).getBytes(StandardCharsets.UTF_8),
false,
"j",
"json"),
JSONFILE("application/json",
"json",
labyrinth -> JsonRenderer.newInstance().render(labyrinth).getBytes(StandardCharsets.UTF_8),
true,
"s",
"jsonfile"),
PDF("application/pdf",
"pdf",
labyrinth -> PDFRenderer.newInstance().render(labyrinth).toByteArray(),