feat: レスポンスをutilで作成するように

This commit is contained in:
usbharu 2023-04-08 16:59:35 +09:00
parent 88fd245d3f
commit bdb538afd9
1 changed files with 5 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package dev.usbharu.hideout.routing.activitypub
import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.config.Config
import dev.usbharu.hideout.exception.ParameterNotExistException import dev.usbharu.hideout.exception.ParameterNotExistException
import dev.usbharu.hideout.plugins.respondAp
import dev.usbharu.hideout.service.activitypub.ActivityPubUserService import dev.usbharu.hideout.service.activitypub.ActivityPubUserService
import dev.usbharu.hideout.util.HttpUtil.Activity import dev.usbharu.hideout.util.HttpUtil.Activity
import dev.usbharu.hideout.util.HttpUtil.JsonLd import dev.usbharu.hideout.util.HttpUtil.JsonLd
@ -17,8 +18,10 @@ fun Routing.usersAP(activityPubUserService: ActivityPubUserService) {
val name = val name =
call.parameters["name"] ?: throw ParameterNotExistException("Parameter(name='name') does not exist.") call.parameters["name"] ?: throw ParameterNotExistException("Parameter(name='name') does not exist.")
val person = activityPubUserService.getPersonByName(name) val person = activityPubUserService.getPersonByName(name)
call.response.header("Content-Type", ContentType.Application.Activity.toString()) return@handle call.respondAp(
return@handle call.respond(HttpStatusCode.OK, Config.configData.objectMapper.writeValueAsString(person)) person,
HttpStatusCode.OK
)
} }
} }
} }