refactor: ActivityPubのルーティング定義を移動

This commit is contained in:
usbharu 2023-04-01 21:23:09 +09:00
parent 0062829ffe
commit db362fb48b
3 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package dev.usbharu.hideout.routing.activitypub
import io.ktor.server.application.*
import io.ktor.server.routing.*
fun Routing.inbox(){
route("/inbox") {
get {
}
post {
}
}
route("/users/{name}/inbox"){
get {
}
post {
}
}
}

View File

@ -0,0 +1,25 @@
package dev.usbharu.hideout.routing.activitypub
import io.ktor.server.application.*
import io.ktor.server.routing.*
fun Routing.outbox() {
route("/outbox") {
get {
}
post {
}
}
route("/users/{name}/outbox"){
get {
}
post {
}
}
}

View File

@ -0,0 +1,25 @@
package dev.usbharu.hideout.routing.activitypub
import dev.usbharu.hideout.util.HttpUtil.Activity
import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.request.*
import io.ktor.server.routing.*
fun Routing.users(){
route("/users/{name}"){
createChild(ContentTypeRouteSelector(ContentType.Application.Activity)).handle {
}
}
}
class ContentTypeRouteSelector(private val contentType: ContentType) : RouteSelector() {
override fun evaluate(context: RoutingResolveContext, segmentIndex: Int): RouteSelectorEvaluation {
return if (context.call.request.contentType() == contentType) {
RouteSelectorEvaluation.Constant
} else {
RouteSelectorEvaluation.Failed
}
}
}