Compare commits
No commits in common. "e56b7bb5b05bf879eb1cd64202cd1f71f7ade7be" and "b7c087d53c66e57701dcae0e7ce8f8b4d1c566fa" have entirely different histories.
e56b7bb5b0
...
b7c087d53c
@ -22,6 +22,21 @@ import java.io.File
|
|||||||
|
|
||||||
fun Application.configureCharacter() {
|
fun Application.configureCharacter() {
|
||||||
routing {
|
routing {
|
||||||
|
route("/upload") {
|
||||||
|
get("/{name}") {
|
||||||
|
val fileName = call.parameters["name"] ?: run {
|
||||||
|
call.sendNotFound()
|
||||||
|
return@get
|
||||||
|
}
|
||||||
|
val file = File("./upload/$fileName")
|
||||||
|
if(!file.exists()) {
|
||||||
|
call.sendNotFound()
|
||||||
|
return@get
|
||||||
|
}
|
||||||
|
call.respondFile(file)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
route("/api") {
|
route("/api") {
|
||||||
route("/v1") {
|
route("/v1") {
|
||||||
get("/characters") {
|
get("/characters") {
|
||||||
|
|||||||
@ -7,11 +7,8 @@ import com.ray650128.model.User
|
|||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.serialization.gson.*
|
import io.ktor.serialization.gson.*
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
import io.ktor.server.http.content.*
|
|
||||||
import io.ktor.server.plugins.contentnegotiation.*
|
import io.ktor.server.plugins.contentnegotiation.*
|
||||||
import io.ktor.server.plugins.cors.routing.*
|
import io.ktor.server.plugins.cors.routing.*
|
||||||
import io.ktor.server.routing.*
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
fun Application.configureModules() {
|
fun Application.configureModules() {
|
||||||
|
|
||||||
@ -48,9 +45,4 @@ fun Application.configureModules() {
|
|||||||
allowCredentials = true
|
allowCredentials = true
|
||||||
allowNonSimpleContentTypes = true
|
allowNonSimpleContentTypes = true
|
||||||
}
|
}
|
||||||
routing {
|
|
||||||
staticFiles("/", File("web"))
|
|
||||||
staticFiles("/character", File("web/character"))
|
|
||||||
staticFiles("/upload", File("web"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user