|
|
@@ -120,7 +120,7 @@ internal inline fun Route.httpAuthedMultiPart(
|
|
|
path: String, crossinline body: Strategy2<HttpAuthedSession, List<PartData>>
|
|
|
) = routeWithHandle(path, HttpMethod.Post) {
|
|
|
val parts = call.receiveMultipart().readAllParts()
|
|
|
- val sessionKey = call.parameters["sessionKey"] ?: MahContext.SINGLE_SESSION_KEY
|
|
|
+ val sessionKey = parts.valueOrNull("sessionKey") ?: MahContext.SINGLE_SESSION_KEY
|
|
|
|
|
|
this.body(getAuthedSession(sessionKey), parts)
|
|
|
}
|
|
|
@@ -207,11 +207,13 @@ internal inline fun <reified R> PipelineContext<Unit, ApplicationCall>.paramOrNu
|
|
|
/**
|
|
|
* 接收 http multi part 值类型
|
|
|
*/
|
|
|
-internal fun List<PartData>.value(name: String) =
|
|
|
+internal fun List<PartData>.value(name: String) = valueOrNull(name) ?: throw IllegalParamException()
|
|
|
+
|
|
|
+internal fun List<PartData>.valueOrNull(name: String) =
|
|
|
try {
|
|
|
(filter { it.name == name }[0] as PartData.FormItem).value
|
|
|
} catch (e: Exception) {
|
|
|
- throw IllegalParamException()
|
|
|
+ null
|
|
|
}
|
|
|
|
|
|
/**
|