@@ -22,30 +22,22 @@ trait ApiServer:
2222 def start (endpoints : List [HttpEndpoint ]): IO [Unit ]
2323
2424 @ targetName(" startWithEndpoints" )
25- def start (endpoints : HttpEndpoint * ): IO [Unit ] =
26- start(endpoints.toList)
25+ def start (endpoints : HttpEndpoint * ): IO [Unit ] = start(endpoints.toList)
2726
2827 @ targetName(" startWithControllers" )
29- def start (controllers : Controller * ): IO [Unit ] =
30- start(controllers.toList.flatten)
28+ def start (controllers : Controller * ): IO [Unit ] = start(controllers.toList.flatten)
3129
3230end ApiServer
3331
3432def server (using p : Pillars ): Run [ApiServer ] = p.apiServer
3533
3634object ApiServer :
37- def init (
38- config : Config ,
39- infos : AppInfo ,
40- observability : Observability ,
41- logger : Scribe [IO ]
42- ): ApiServer =
35+ def init (config : Config , infos : AppInfo , observability : Observability , logger : Scribe [IO ]): ApiServer =
4336 (endpoints : List [HttpEndpoint ]) =>
4437 IO .whenA(config.enabled):
4538 for
4639 _ <- logger.info(s " Starting API server on ${config.http.host}: ${config.http.port}" )
47- _ <- HttpServer
48- .build(" api" , config.http, config.openApi, infos, observability, endpoints)
40+ _ <- HttpServer .build(" api" , config.http, config.openApi, infos, observability, endpoints)
4941 .onFinalizeCase:
5042 case ExitCase .Errored (e) => logger.error(s " API server stopped with error: $e" )
5143 case _ => logger.info(" API server stopped" )
@@ -62,14 +54,10 @@ object ApiServer:
6254 openApi : HttpServer .Config .OpenAPI = HttpServer .Config .OpenAPI ()
6355 ) extends pillars.Config
6456
65- given Configuration = Configuration .default.withKebabCaseMemberNames.withKebabCaseConstructorNames.withDefaults
57+ given Configuration = pillars. Config .defaultCirceConfig
6658 given Codec [Config ] = Codec .AsObject .derivedConfigured
6759
68- private val defaultHttp = HttpServer .Config (
69- host = host " 0.0.0.0 " ,
70- port = port " 9876 " ,
71- logging = Logging .HttpConfig ()
72- )
60+ private val defaultHttp = HttpServer .Config (host = host " 0.0.0.0 " , port = port " 9876 " , logging = Logging .HttpConfig ())
7361
7462 def noop : ApiServer = _ => IO .unit
7563end ApiServer
0 commit comments