๐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
keytool -keystore mykey.jks -alias mykey -keyalg RSA -keysize 2048 -sigalg SHA256withRSA -genkey -validity 3650 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package calculator | |
actual fun log(msg: String) = console.log(msg) | |
fun main(args: Array<String>) { | |
Calculator.add(1, 2) | |
Calculator.subtract(1, 2) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package calculator | |
actual fun log(msg: String) = System.out.println(msg) | |
fun main(args: Array<String>) { | |
Calculator.add(1, 2) | |
Calculator.subtract(1, 2) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package calculator | |
expect fun log(msg: String) | |
object Calculator { | |
fun add(x: Int, y: Int): Int { | |
log("add -> $x $y") | |
return x + y | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id:0 | |
event:random | |
data:751025203 | |
id:1 | |
event:random | |
data:-1591883873 | |
id:2 | |
event:random |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.http.codec.ServerSentEvent; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
import reactor.core.publisher.Flux; | |
import reactor.util.function.Tuples; | |
import java.time.Duration; | |
import java.util.concurrent.ThreadLocalRandom; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(SpringRunner.class) | |
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) | |
public class FunctionalStarterApplicationTests { | |
@Autowired | |
private TestRestTemplate restTemplate; | |
@Test | |
public void calculate() { | |
assertThat(doCalculate("add", "3", "5")).isEqualTo("8"); | |
assertThat(doCalculate("subtract", "3", "5")).isEqualTo("-2"); | |
assertThat(doCalculate("multiply", "3", "5")).isEqualTo("15"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class Config { | |
@Bean | |
@Autowired | |
public RouterFunction<ServerResponse> routerFunction(final CalculatorHandler calculatorHandler) { | |
return RouterFunctions.route(RequestPredicates.path("/calculator"), request -> | |
request.queryParam("operator").map(operator -> | |
Mono.justOrEmpty( | |
ReflectionUtils.findMethod(CalculatorHandler.class, operator, ServerRequest.class)) | |
.flatMap(method -> (Mono<ServerResponse>) ReflectionUtils |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class CalculatorHandler { | |
public Mono<ServerResponse> add(final ServerRequest request) { | |
return calculate(request, (v1, v2) -> v1 + v2); | |
} | |
public Mono<ServerResponse> subtract(final ServerRequest request) { | |
return calculate(request, (v1, v2) -> v1 - v2); | |
} | |
public Mono<ServerResponse> multiply(final ServerRequest request) { | |
return calculate(request, (v1, v2) -> v1 * v2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM phusion/baseimage | |
CMD ["/sbin/my_init"] | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
bzip2 \ | |
unzip \ | |
xz-utils \ | |
&& rm -rf /var/lib/apt/lists/* |