diff --git a/app/uk/gov/hmrc/agentclientauthorisation/controllers/MicroserviceHelloWorld.scala b/app/uk/gov/hmrc/agentclientauthorisation/controllers/MicroserviceHelloWorld.scala index c3e90b89..e274de3f 100644 --- a/app/uk/gov/hmrc/agentclientauthorisation/controllers/MicroserviceHelloWorld.scala +++ b/app/uk/gov/hmrc/agentclientauthorisation/controllers/MicroserviceHelloWorld.scala @@ -1,15 +1,31 @@ +/* + * Copyright 2016 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package uk.gov.hmrc.agentclientauthorisation.controllers -import uk.gov.hmrc.play.microservice.controller.BaseController -import uk.gov.hmrc.play.http.logging.MdcLoggingExecutionContext._ import play.api.mvc._ +import uk.gov.hmrc.play.microservice.controller.BaseController + import scala.concurrent.Future object MicroserviceHelloWorld extends MicroserviceHelloWorld -trait MicroserviceHelloWorld extends BaseController { +class MicroserviceHelloWorld extends BaseController { def hello() = Action.async { implicit request => Future.successful(Ok("Hello world")) } -} \ No newline at end of file +} diff --git a/app/uk/gov/hmrc/agentclientauthorisation/microserviceGlobal.scala b/app/uk/gov/hmrc/agentclientauthorisation/microserviceGlobal.scala index cd5e680f..70ccb70e 100644 --- a/app/uk/gov/hmrc/agentclientauthorisation/microserviceGlobal.scala +++ b/app/uk/gov/hmrc/agentclientauthorisation/microserviceGlobal.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2016 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package uk.gov.hmrc.agentclientauthorisation import com.typesafe.config.Config @@ -34,7 +50,7 @@ object MicroserviceAuthFilter extends AuthorisationFilter { override def controllerNeedsAuth(controllerName: String): Boolean = ControllerConfiguration.paramsForController(controllerName).needsAuth } -object MicroserviceGlobal extends DefaultMicroserviceGlobal with RunMode { +trait MicroserviceGlobal extends DefaultMicroserviceGlobal with RunMode with ServiceRegistry with ControllerRegistry { override val auditConnector = MicroserviceAuditConnector override def microserviceMetricsConfig(implicit app: Application): Option[Configuration] = app.configuration.getConfig(s"microservice.metrics") @@ -44,4 +60,10 @@ object MicroserviceGlobal extends DefaultMicroserviceGlobal with RunMode { override val microserviceAuditFilter = MicroserviceAuditFilter override val authFilter = Some(MicroserviceAuthFilter) + + override def getControllerInstance[A](controllerClass: Class[A]): A = { + getController(controllerClass) + } } + +object MicroserviceGlobal extends MicroserviceGlobal diff --git a/app/uk/gov/hmrc/agentclientauthorisation/microserviceWiring.scala b/app/uk/gov/hmrc/agentclientauthorisation/microserviceWiring.scala index 85d86a8d..ba038e37 100644 --- a/app/uk/gov/hmrc/agentclientauthorisation/microserviceWiring.scala +++ b/app/uk/gov/hmrc/agentclientauthorisation/microserviceWiring.scala @@ -1,5 +1,23 @@ +/* + * Copyright 2016 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package uk.gov.hmrc.agentclientauthorisation +import play.api.mvc.Controller +import uk.gov.hmrc.agentclientauthorisation.controllers.MicroserviceHelloWorld import uk.gov.hmrc.play.audit.http.config.LoadAuditingConfig import uk.gov.hmrc.play.audit.http.connector.AuditConnector import uk.gov.hmrc.play.auth.microservice.connectors.AuthConnector @@ -18,3 +36,19 @@ object MicroserviceAuditConnector extends AuditConnector with RunMode { object MicroserviceAuthConnector extends AuthConnector with ServicesConfig { override val authBaseUrl = baseUrl("auth") } + +trait ServiceRegistry extends ServicesConfig { + + // Instantiate services here + +} + +trait ControllerRegistry { + registry: ServiceRegistry => + + private lazy val controllers = Map[Class[_], Controller]( + classOf[MicroserviceHelloWorld] -> new MicroserviceHelloWorld() + ) + + def getController[A](controllerClass: Class[A]) : A = controllers(controllerClass).asInstanceOf[A] +} diff --git a/conf/application.conf b/conf/application.conf index 14e70235..b9b66748 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -1,3 +1,16 @@ +# Copyright 2016 HM Revenue & Customs +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # This is the main configuration file for the application. # ~~~~~ @@ -138,5 +151,3 @@ microservice { } } - - diff --git a/project/plugins.sbt b/project/plugins.sbt index f83c2688..68bec413 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -4,8 +4,12 @@ resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/ addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "1.0.0") -addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "467a8b417f9d90ab863f3172f1bebe1d7c49706b") +addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "0.8.0") addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "0.11.0") addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.10") + +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.3.5") + +addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0")