/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/java/java-503-272-002/main.java
22 строки
692 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
package com.example.demo.web; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import java.util.Map; @RestController public class ApiController { @GetMapping("/api/public") public Map<String, String> publicEndpoint() { return Map.of("message", "ok"); } @GetMapping("/api/private") public Map<String, String> privateEndpoint(@AuthenticationPrincipal UserDetails user) { return Map.of("message", "hello, " + user.getUsername()); } }