From 6b5426a8276a7d0254a5d16e325e8e43805fee78 Mon Sep 17 00:00:00 2001
From: usbharu <64310155+usbharu@users.noreply.github.com>
Date: Sun, 24 Sep 2023 11:56:31 +0900
Subject: [PATCH] =?UTF-8?q?feat:=20hostmeta=E3=81=AE=E3=82=A8=E3=83=B3?=
=?UTF-8?q?=E3=83=89=E3=83=9D=E3=82=A4=E3=83=B3=E3=83=88=E3=82=92=E8=BF=BD?=
=?UTF-8?q?=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../wellknown/HostMetaController.kt | 42 +++++++++++++++++++
1 file changed, 42 insertions(+)
create mode 100644 src/main/kotlin/dev/usbharu/hideout/controller/wellknown/HostMetaController.kt
diff --git a/src/main/kotlin/dev/usbharu/hideout/controller/wellknown/HostMetaController.kt b/src/main/kotlin/dev/usbharu/hideout/controller/wellknown/HostMetaController.kt
new file mode 100644
index 00000000..1c92dc73
--- /dev/null
+++ b/src/main/kotlin/dev/usbharu/hideout/controller/wellknown/HostMetaController.kt
@@ -0,0 +1,42 @@
+package dev.usbharu.hideout.controller.wellknown
+
+import dev.usbharu.hideout.config.ApplicationConfig
+import org.intellij.lang.annotations.Language
+import org.springframework.http.HttpStatus
+import org.springframework.http.ResponseEntity
+import org.springframework.web.bind.annotation.GetMapping
+import org.springframework.web.bind.annotation.RestController
+
+@RestController
+class HostMetaController(private val applicationConfig: ApplicationConfig) {
+
+ val xml = //language=XML
+ """
+
+
+"""
+
+ @Language("JSON")
+ val json = """{
+ "links": [
+ {
+ "rel": "lrdd",
+ "type": "application/jrd+json",
+ "template": "${applicationConfig.url}/.well-known/webfinger?resource={uri}"
+ }
+ ]
+}"""
+
+ @GetMapping("/.well-known/host-meta", produces = ["application/xml"])
+ fun hostmeta(): ResponseEntity {
+ return ResponseEntity(xml, HttpStatus.OK)
+ }
+
+ @GetMapping("/.well-known/host-meta.json", produces = ["application/json"])
+ fun hostmetJson(): ResponseEntity {
+ return ResponseEntity(json, HttpStatus.OK)
+ }
+
+
+}