Skip to content

Commit 9e8ac77

Browse files
committed
fix compile errors
1 parent ec441a0 commit 9e8ac77

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

rest-service/src/main/kotlin/mb/Main.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import org.veupathdb.lib.container.jaxrs.config.Options
77
import org.veupathdb.lib.container.jaxrs.health.Dependency
88
import org.veupathdb.lib.container.jaxrs.server.ContainerResources
99
import org.veupathdb.lib.container.jaxrs.server.Server
10-
import org.veupathdb.lib.container.jaxrs.server.middleware.PrometheusFilter
1110
import org.veupathdb.lib.prom.PrometheusJVM
1211
import java.util.concurrent.Executors
1312
import java.util.concurrent.ScheduledExecutorService
@@ -22,11 +21,6 @@ object Main : Server() {
2221
enableAccountDB()
2322
enableUserDB()
2423

25-
// Add path transform to exclude job IDs from endpoint metrics.
26-
PrometheusFilter.setPathTransform {
27-
it.replace(Regex("[0-9A-Fa-f]{32}"), "{id}")
28-
}
29-
3024
PrometheusJVM.enable()
3125

3226
bgTasks.scheduleAtFixedRate(JobCleanup, 0, 24, TimeUnit.HOURS)
@@ -35,10 +29,6 @@ object Main : Server() {
3529
@JvmStatic
3630
fun main(args: Array<String>) = start(args)
3731

38-
fun startServer(args: Array<String>) {
39-
start(args)
40-
}
41-
4232
override fun onShutdown() {
4333
super.onShutdown()
4434
bgTasks.shutdown()

rest-service/src/main/kotlin/mb/api/controller/utils.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package mb.api.controller
22

3-
import org.veupathdb.lib.container.jaxrs.model.User
43
import org.veupathdb.lib.container.jaxrs.providers.UserProvider
54
import jakarta.ws.rs.BadRequestException
65
import jakarta.ws.rs.InternalServerErrorException
@@ -12,17 +11,16 @@ private const val ErrNoUser = "request reached authenticated endpoint with no us
1211

1312
fun noUserExcept(): RuntimeException = InternalServerErrorException(ErrNoUser)
1413

15-
fun ContainerRequest.requireUser(): User {
16-
return UserProvider.lookupUser(this).orElseThrow(::noUserExcept)
17-
}
14+
fun ContainerRequest.requireUser() =
15+
UserProvider.lookupUser(this).orElseThrow(::noUserExcept)!!
1816

1917
fun ContainerRequest.requireUserID(): Long = requireUser().userId
2018

2119
fun <T> enforceBody(value: T?): T =
2220
value ?: throw BadRequestException("Request missing one or more input body fields.")
2321

2422
inline fun <R> errorWrap(fn: () -> R): R = try { fn() }
25-
catch (e: Throwable) { throw if (e is WebApplicationException) e else InternalServerErrorException(e) }
23+
catch (e: Throwable) { throw e as? WebApplicationException ?: InternalServerErrorException(e) }
2624

2725
fun hashIDorThrow(raw: String, fn: () -> Exception): HashID {
2826
try {

0 commit comments

Comments
 (0)