package Ġorg . six dou glas . git . routing Ċ Ċ import Ġorg . six dou glas . git . environment . Environment Ċ import Ġorg . six dou glas . git . environment . Environment Component Ċ import Ġorg . six dou glas . git . server . Server Ċ import Ġorg . springframework . http . MediaType Ċ import Ġorg . springframework . stereotype . Component Ċ import Ġorg . springframework . web . reactive . function . server . Server Request Ċ import Ġorg . springframework . web . reactive . function . server . Server Response Ċ import Ġreactor . core . publisher . Mono Ċ Ċ @ Component Ċ internal Ġclass ĠEnvironment Handler Ġinternal Ġconstructor Ġ( internal Ġval Ġenvironment Service : ĠEnvironment Component ) Ġ{ ĊĠĠĠ Ġfun Ġget Environments ( server Request : ĠServer Request ): ĠMono < out ĠServer Response > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠServer Response . ok (). contentType ( MediaType . APPLICATION _ JSON ). body ( environment Service . get Environments (), ĠEnvironment :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Environment Servers ( server Request : ĠServer Request ): ĠMono < out ĠServer Response > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġenvironment Id : Int Ġ= ĠInteger . valueOf ( server Request . path Variable (" environment Id ")) ĊĠĠĠĠĠĠĠ Ġreturn ĠServer Response . ok (). contentType ( MediaType . APPLICATION _ JSON ). body ( environment Service . get Environment Servers ( environment Id ), ĠServer :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġadd Environment ( server Request : ĠServer Request ): ĠMono < out ĠServer Response > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġrequest Environment : ĠMono < Environment > Ġ= Ġserver Request . body To Mono ( Environment :: class . java ) ĊĠĠĠĠĠĠĠ Ġreturn Ġrequest Environment . flatMap Ġ{ Ġenvironment Ġ-> Ġ ĠServer Response . ok (). contentType ( MediaType . APPLICATION _ JSON ). body ( environment Service . add Environment ( environment ), ĠEnvironment :: class . java ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġadd Environment Server ( server Request : ĠServer Request ): ĠMono < out ĠServer Response > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġenvironment Id : Int Ġ= ĠInteger . valueOf ( server Request . path Variable (" environment Id ")) ĊĠĠĠĠĠĠĠ Ġval Ġrequest Server : ĠMono < Server > Ġ= Ġserver Request . body To Mono ( Server :: class . java ) ĊĠĠĠĠĠĠĠ Ġreturn Ġrequest Server . flatMap Ġ{ Ġserver Ġ-> Ġ ĠServer Response . ok (). contentType ( MediaType . APPLICATION _ JSON ). body ( environment Service . add Environment Server ( environment Id , Ġserver ), ĠServer :: class . java ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġupdate Environment ( server Request : ĠServer Request ): ĠMono < out ĠServer Response > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġenvironment Id : Int Ġ= ĠInteger . valueOf ( server Request . path Variable (" environment Id ")) ĊĠĠĠĠĠĠĠ Ġval Ġrequest Environment : ĠMono < Environment > Ġ= Ġserver Request . body To Mono ( Environment :: class . java ) ĊĠĠĠĠĠĠĠ Ġreturn Ġrequest Environment . flatMap Ġ{ Ġenvironment Ġ-> ĠServer Response . ok (). contentType ( MediaType . APPLICATION _ JSON ). body ( environment Service . update Environment ( environment Id , Ġenvironment ), ĠEnvironment :: class . java ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġdelete Environment ( server Request : ĠServer Request ): ĠMono < out ĠServer Response > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġenvironment Id : Int Ġ= ĠInteger . valueOf ( server Request . path Variable (" environment Id ")) ĊĠĠĠĠĠĠĠ Ġreturn ĠServer Response . ok (). contentType ( MediaType . APPLICATION _ JSON ). body ( environment Service . delete Environment ( environment Id ), ĠEnvironment :: class . java ) ĊĠĠĠ Ġ} Ċ Ċ }