mirror of https://github.com/usbharu/Hideout.git
feat: host-metaを返せるように
This commit is contained in:
parent
4679995144
commit
253e25e51d
|
@ -0,0 +1,20 @@
|
||||||
|
package dev.usbharu.hideout.activitypub.application.hostmeta
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper
|
||||||
|
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty
|
||||||
|
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement
|
||||||
|
|
||||||
|
@JacksonXmlRootElement(localName = "XRD", namespace = "http://docs.oasis-open.org/ns/xri/xrd-1.0")
|
||||||
|
class WebHostMetadata(
|
||||||
|
@JacksonXmlProperty(localName = "Link", namespace = "http://docs.oasis-open.org/ns/xri/xrd-1.0")
|
||||||
|
@JacksonXmlElementWrapper(useWrapping = false)
|
||||||
|
@JsonProperty("links")
|
||||||
|
val links: List<Link>,
|
||||||
|
)
|
||||||
|
|
||||||
|
class Link(
|
||||||
|
@JacksonXmlProperty(localName = "rel", isAttribute = true) val rel: String,
|
||||||
|
@JacksonXmlProperty(localName = "template", isAttribute = true) val template: String,
|
||||||
|
@JacksonXmlProperty(localName = "type", isAttribute = true) val type: String,
|
||||||
|
)
|
|
@ -23,6 +23,8 @@ class ActivityPubSecurityConfig {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
authorizeHttpRequests {
|
authorizeHttpRequests {
|
||||||
|
authorize(GET, "/.well-known/**", permitAll)
|
||||||
|
authorize(GET, "/error", permitAll)
|
||||||
authorize(POST, "/inbox", permitAll)
|
authorize(POST, "/inbox", permitAll)
|
||||||
authorize(POST, "/users/{username}/inbox", permitAll)
|
authorize(POST, "/users/{username}/inbox", permitAll)
|
||||||
authorize(GET, "/outbox", permitAll)
|
authorize(GET, "/outbox", permitAll)
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package dev.usbharu.hideout.activitypub.interfaces.wellknown
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.activitypub.application.hostmeta.Link
|
||||||
|
import dev.usbharu.hideout.activitypub.application.hostmeta.WebHostMetadata
|
||||||
|
import org.springframework.core.annotation.Order
|
||||||
|
import org.springframework.http.MediaType
|
||||||
|
import org.springframework.http.ResponseEntity
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping
|
||||||
|
import org.springframework.web.bind.annotation.RestController
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/.well-known")
|
||||||
|
class HostmetaController {
|
||||||
|
@Order(1)
|
||||||
|
@GetMapping("/host-meta")
|
||||||
|
fun hostmeta(): ResponseEntity<WebHostMetadata> {
|
||||||
|
return ResponseEntity.ok().contentType(MediaType("application", "xrd+xml"))
|
||||||
|
.body(WebHostMetadata(listOf(Link("a", "b", "c"))))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Order(2)
|
||||||
|
@GetMapping("/host-meta", produces = ["application/json"])
|
||||||
|
fun hostmetaJson(): WebHostMetadata {
|
||||||
|
return WebHostMetadata(listOf(Link("a", "b", "c")))
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/host-meta.json", produces = ["application/json"])
|
||||||
|
fun hostmetaJson2(): WebHostMetadata {
|
||||||
|
return WebHostMetadata(listOf(Link("a", "b", "c")))
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue