File tree Expand file tree Collapse file tree 2 files changed +3
-15
lines changed
rest-service/src/main/kotlin/mb Expand file tree Collapse file tree 2 files changed +3
-15
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ import org.veupathdb.lib.container.jaxrs.config.Options
77import org.veupathdb.lib.container.jaxrs.health.Dependency
88import org.veupathdb.lib.container.jaxrs.server.ContainerResources
99import org.veupathdb.lib.container.jaxrs.server.Server
10- import org.veupathdb.lib.container.jaxrs.server.middleware.PrometheusFilter
1110import org.veupathdb.lib.prom.PrometheusJVM
1211import java.util.concurrent.Executors
1312import 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()
Original file line number Diff line number Diff line change 11package mb.api.controller
22
3- import org.veupathdb.lib.container.jaxrs.model.User
43import org.veupathdb.lib.container.jaxrs.providers.UserProvider
54import jakarta.ws.rs.BadRequestException
65import jakarta.ws.rs.InternalServerErrorException
@@ -12,17 +11,16 @@ private const val ErrNoUser = "request reached authenticated endpoint with no us
1211
1312fun 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
1917fun ContainerRequest.requireUserID (): Long = requireUser().userId
2018
2119fun <T > enforceBody (value : T ? ): T =
2220 value ? : throw BadRequestException (" Request missing one or more input body fields." )
2321
2422inline 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
2725fun hashIDorThrow (raw : String , fn : () -> Exception ): HashID {
2826 try {
You can’t perform that action at this time.
0 commit comments