diff --git a/src/main/java/ru/ulstu/is/labwork/LabworkApplication.java b/src/main/java/ru/ulstu/is/labwork/LabworkApplication.java index 98213be..e99cf97 100644 --- a/src/main/java/ru/ulstu/is/labwork/LabworkApplication.java +++ b/src/main/java/ru/ulstu/is/labwork/LabworkApplication.java @@ -18,4 +18,28 @@ public class LabworkApplication { public String good_morning(@RequestParam(value = "name", defaultValue = "Sir") String name) { return String.format("Good morning, %s!", name); } + @GetMapping("/sum") + public int sum( @RequestParam(value = "num1", defaultValue = "0") int num1, + @RequestParam(value = "num2", defaultValue = "0") int num2) + { + return num1 + num2; + } + @GetMapping("/sub") + public int sub( @RequestParam(value = "num1", defaultValue = "0") int num1, + @RequestParam(value = "num2", defaultValue = "0") int num2) + { + return num1 - num2; + } + @GetMapping("/mul") + public int mul( @RequestParam(value = "num1", defaultValue = "0") int num1, + @RequestParam(value = "num2", defaultValue = "0") int num2) + { + return num1 * num2; + } + @GetMapping("/div") + public int div( @RequestParam(value = "num1", defaultValue = "0") int num1, + @RequestParam(value = "num2", defaultValue = "0") int num2) + { + return num1 / num2; + } } diff --git a/src/main/java/ru/ulstu/is/labwork/WebConfiguration.java b/src/main/java/ru/ulstu/is/labwork/WebConfiguration.java new file mode 100644 index 0000000..2de704e --- /dev/null +++ b/src/main/java/ru/ulstu/is/labwork/WebConfiguration.java @@ -0,0 +1,13 @@ +package ru.ulstu.is.labwork; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class WebConfiguration implements WebMvcConfigurer { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**").allowedMethods("*"); + } +} \ No newline at end of file