1 /*
2  *  Make.org Core API
3  *  Copyright (C) 2018 Make.org
4  *
5  * This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Affero General Public License as
7  *  published by the Free Software Foundation, either version 3 of the
8  *  License, or (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Affero General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Affero General Public License
16  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  *
18  */
19 
20 package org.make.api.technical.healthcheck
21 import akka.http.scaladsl.server.{Directives, Route}
22 import io.swagger.annotations._
23 import org.make.api.operation.OperationServiceComponent
24 import org.make.api.question.QuestionServiceComponent
25 
26 import javax.ws.rs.Path
27 import org.make.api.technical.MakeDirectives.MakeDirectivesDependencies
28 import org.make.api.technical.MakeAuthenticationDirectives
29 import org.make.api.technical.directives.FutureDirectivesExtensions._
30 import org.make.core.HttpCodes
31 
32 @Api(value = "Health Check")
33 @Path(value = "/")
34 trait HealthCheckApi extends Directives {
35 
36   @ApiOperation(value = "healthcheck", httpMethod = "GET", code = HttpCodes.OK)
37   @ApiResponses(
38     value = Array(new ApiResponse(code = HttpCodes.OK, message = "Ok", response = classOf[Map[String, String]]))
39   )
40   @Path(value = "/healthcheck")
41   def healthCheck: Route
42 
43   final def routes: Route = healthCheck
44 }
45 
46 trait HealthCheckApiComponent {
47   def healthCheckApi: HealthCheckApi
48 }
49 
50 trait DefaultHealthCheckApiComponent extends HealthCheckApiComponent with MakeAuthenticationDirectives {
51   this: MakeDirectivesDependencies
52     with HealthCheckServiceComponent
53     with QuestionServiceComponent
54     with OperationServiceComponent =>
55 
56   override lazy val healthCheckApi: HealthCheckApi = new DefaultHealthCheckApi
57 
58   class DefaultHealthCheckApi extends HealthCheckApi {
59     def healthCheck: Route = get {
60       path("healthcheck") {
61         makeOperation("HealthCheck") { _ =>
62           healthCheckService
63             .runAllHealthChecks()
64             .asDirective
65             .apply(complete(_))
66         }
67       }
68     }
69   }
70 
71 }
Line Stmt Id Pos Tree Symbol Tests Code
43 35776 1632 - 1643 Select org.make.api.technical.healthcheck.HealthCheckApi.healthCheck HealthCheckApi.this.healthCheck
59 49669 2133 - 2136 Select akka.http.scaladsl.server.directives.MethodDirectives.get DefaultHealthCheckApi.this.get
59 51260 2133 - 2354 Apply scala.Function1.apply server.this.Directive.addByNameNullaryApply(DefaultHealthCheckApi.this.get).apply(server.this.Directive.addByNameNullaryApply(DefaultHealthCheckApi.this.path[Unit](DefaultHealthCheckApi.this._segmentStringToPathMatcher("healthcheck"))).apply(server.this.Directive.addDirectiveApply[(org.make.core.RequestContext,)](DefaultHealthCheckApiComponent.this.makeOperation("HealthCheck", DefaultHealthCheckApiComponent.this.makeOperation$default$2, DefaultHealthCheckApiComponent.this.makeOperation$default$3))(util.this.ApplyConverter.hac1[org.make.core.RequestContext]).apply(((x$1: org.make.core.RequestContext) => server.this.Directive.addDirectiveApply[(Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse],)](org.make.api.technical.directives.FutureDirectivesExtensions.FutureWithRoutes[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](DefaultHealthCheckApiComponent.this.healthCheckService.runAllHealthChecks()).asDirective)(util.this.ApplyConverter.hac1[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]]).apply(((x$2: Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]) => DefaultHealthCheckApi.this.complete(marshalling.this.ToResponseMarshallable.apply[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](x$2)(marshalling.this.Marshaller.liftMarshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](DefaultHealthCheckApiComponent.this.marshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](circe.this.Encoder.encodeSeq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse](HealthCheck.this.HealthCheckResponse.encoderSuccess), DefaultHealthCheckApiComponent.this.marshaller$default$2[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]]))))))))))
60 33482 2145 - 2348 Apply scala.Function1.apply server.this.Directive.addByNameNullaryApply(DefaultHealthCheckApi.this.path[Unit](DefaultHealthCheckApi.this._segmentStringToPathMatcher("healthcheck"))).apply(server.this.Directive.addDirectiveApply[(org.make.core.RequestContext,)](DefaultHealthCheckApiComponent.this.makeOperation("HealthCheck", DefaultHealthCheckApiComponent.this.makeOperation$default$2, DefaultHealthCheckApiComponent.this.makeOperation$default$3))(util.this.ApplyConverter.hac1[org.make.core.RequestContext]).apply(((x$1: org.make.core.RequestContext) => server.this.Directive.addDirectiveApply[(Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse],)](org.make.api.technical.directives.FutureDirectivesExtensions.FutureWithRoutes[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](DefaultHealthCheckApiComponent.this.healthCheckService.runAllHealthChecks()).asDirective)(util.this.ApplyConverter.hac1[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]]).apply(((x$2: Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]) => DefaultHealthCheckApi.this.complete(marshalling.this.ToResponseMarshallable.apply[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](x$2)(marshalling.this.Marshaller.liftMarshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](DefaultHealthCheckApiComponent.this.marshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](circe.this.Encoder.encodeSeq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse](HealthCheck.this.HealthCheckResponse.encoderSuccess), DefaultHealthCheckApiComponent.this.marshaller$default$2[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]])))))))))
60 41555 2150 - 2163 ApplyImplicitView akka.http.scaladsl.server.ImplicitPathMatcherConstruction._segmentStringToPathMatcher DefaultHealthCheckApi.this._segmentStringToPathMatcher("healthcheck")
60 33695 2145 - 2164 Apply akka.http.scaladsl.server.directives.PathDirectives.path DefaultHealthCheckApi.this.path[Unit](DefaultHealthCheckApi.this._segmentStringToPathMatcher("healthcheck"))
61 34779 2175 - 2175 Select org.make.api.technical.MakeDirectives.makeOperation$default$3 DefaultHealthCheckApiComponent.this.makeOperation$default$3
61 50166 2189 - 2202 Literal <nosymbol> "HealthCheck"
61 42581 2175 - 2175 Select org.make.api.technical.MakeDirectives.makeOperation$default$2 DefaultHealthCheckApiComponent.this.makeOperation$default$2
61 42052 2175 - 2340 Apply scala.Function1.apply server.this.Directive.addDirectiveApply[(org.make.core.RequestContext,)](DefaultHealthCheckApiComponent.this.makeOperation("HealthCheck", DefaultHealthCheckApiComponent.this.makeOperation$default$2, DefaultHealthCheckApiComponent.this.makeOperation$default$3))(util.this.ApplyConverter.hac1[org.make.core.RequestContext]).apply(((x$1: org.make.core.RequestContext) => server.this.Directive.addDirectiveApply[(Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse],)](org.make.api.technical.directives.FutureDirectivesExtensions.FutureWithRoutes[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](DefaultHealthCheckApiComponent.this.healthCheckService.runAllHealthChecks()).asDirective)(util.this.ApplyConverter.hac1[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]]).apply(((x$2: Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]) => DefaultHealthCheckApi.this.complete(marshalling.this.ToResponseMarshallable.apply[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](x$2)(marshalling.this.Marshaller.liftMarshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](DefaultHealthCheckApiComponent.this.marshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](circe.this.Encoder.encodeSeq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse](HealthCheck.this.HealthCheckResponse.encoderSuccess), DefaultHealthCheckApiComponent.this.marshaller$default$2[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]]))))))))
61 43926 2188 - 2188 TypeApply akka.http.scaladsl.server.util.ApplyConverterInstances.hac1 util.this.ApplyConverter.hac1[org.make.core.RequestContext]
61 48089 2175 - 2203 Apply org.make.api.technical.MakeDirectives.makeOperation DefaultHealthCheckApiComponent.this.makeOperation("HealthCheck", DefaultHealthCheckApiComponent.this.makeOperation$default$2, DefaultHealthCheckApiComponent.this.makeOperation$default$3)
63 35817 2221 - 2273 Apply org.make.api.technical.healthcheck.HealthCheckService.runAllHealthChecks DefaultHealthCheckApiComponent.this.healthCheckService.runAllHealthChecks()
64 49107 2221 - 2298 Select org.make.api.technical.directives.FutureDirectivesExtensions.FutureWithRoutes.asDirective org.make.api.technical.directives.FutureDirectivesExtensions.FutureWithRoutes[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](DefaultHealthCheckApiComponent.this.healthCheckService.runAllHealthChecks()).asDirective
64 41315 2287 - 2287 TypeApply akka.http.scaladsl.server.util.ApplyConverterInstances.hac1 util.this.ApplyConverter.hac1[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]]
65 35522 2327 - 2327 ApplyToImplicitArgs de.heikoseeberger.akkahttpcirce.BaseCirceSupport.marshaller DefaultHealthCheckApiComponent.this.marshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](circe.this.Encoder.encodeSeq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse](HealthCheck.this.HealthCheckResponse.encoderSuccess), DefaultHealthCheckApiComponent.this.marshaller$default$2[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]])
65 35857 2318 - 2329 Apply akka.http.scaladsl.server.directives.RouteDirectives.complete DefaultHealthCheckApi.this.complete(marshalling.this.ToResponseMarshallable.apply[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](x$2)(marshalling.this.Marshaller.liftMarshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](DefaultHealthCheckApiComponent.this.marshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](circe.this.Encoder.encodeSeq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse](HealthCheck.this.HealthCheckResponse.encoderSuccess), DefaultHealthCheckApiComponent.this.marshaller$default$2[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]]))))
65 33733 2327 - 2327 Select org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse.encoderSuccess HealthCheck.this.HealthCheckResponse.encoderSuccess
65 50204 2327 - 2327 ApplyToImplicitArgs io.circe.Encoder.encodeSeq circe.this.Encoder.encodeSeq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse](HealthCheck.this.HealthCheckResponse.encoderSuccess)
65 47847 2327 - 2327 ApplyToImplicitArgs akka.http.scaladsl.marshalling.LowPriorityToResponseMarshallerImplicits.liftMarshaller marshalling.this.Marshaller.liftMarshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](DefaultHealthCheckApiComponent.this.marshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](circe.this.Encoder.encodeSeq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse](HealthCheck.this.HealthCheckResponse.encoderSuccess), DefaultHealthCheckApiComponent.this.marshaller$default$2[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]]))
65 42341 2327 - 2327 TypeApply de.heikoseeberger.akkahttpcirce.BaseCirceSupport.marshaller$default$2 DefaultHealthCheckApiComponent.this.marshaller$default$2[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]]
65 49623 2221 - 2330 Apply scala.Function1.apply server.this.Directive.addDirectiveApply[(Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse],)](org.make.api.technical.directives.FutureDirectivesExtensions.FutureWithRoutes[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](DefaultHealthCheckApiComponent.this.healthCheckService.runAllHealthChecks()).asDirective)(util.this.ApplyConverter.hac1[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]]).apply(((x$2: Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]) => DefaultHealthCheckApi.this.complete(marshalling.this.ToResponseMarshallable.apply[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](x$2)(marshalling.this.Marshaller.liftMarshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](DefaultHealthCheckApiComponent.this.marshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](circe.this.Encoder.encodeSeq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse](HealthCheck.this.HealthCheckResponse.encoderSuccess), DefaultHealthCheckApiComponent.this.marshaller$default$2[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]]))))))
65 39718 2327 - 2328 ApplyToImplicitArgs akka.http.scaladsl.marshalling.ToResponseMarshallable.apply marshalling.this.ToResponseMarshallable.apply[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](x$2)(marshalling.this.Marshaller.liftMarshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](DefaultHealthCheckApiComponent.this.marshaller[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]](circe.this.Encoder.encodeSeq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse](HealthCheck.this.HealthCheckResponse.encoderSuccess), DefaultHealthCheckApiComponent.this.marshaller$default$2[Seq[org.make.api.technical.healthcheck.HealthCheck.HealthCheckResponse]])))