-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
103a1e5
commit 5076942
Showing
3 changed files
with
41 additions
and
2 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
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
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,30 @@ | ||
package dev.latvian.apps.webutils.html; | ||
|
||
import dev.latvian.apps.webutils.net.FileResponse; | ||
import dev.latvian.apps.webutils.net.Response; | ||
import io.javalin.http.HttpStatus; | ||
|
||
import java.io.Writer; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
public class XMLTag extends PairedTag { | ||
public XMLTag(String tag) { | ||
super(tag); | ||
} | ||
|
||
@Override | ||
public Tag getRoot() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public void write(Writer writer) throws Throwable { | ||
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); | ||
super.write(writer); | ||
} | ||
|
||
@Override | ||
public Response asResponse(HttpStatus status) { | ||
return FileResponse.of(status, "text/xml; charset=utf-8", toString().getBytes(StandardCharsets.UTF_8)); | ||
} | ||
} |