40 lines
1.3 KiB
Java
40 lines
1.3 KiB
Java
/*
|
|
* Ardiansyah | http://ard.web.id
|
|
*
|
|
*/
|
|
package id.web.ard.springbootwebfluxjjwt.rest;
|
|
|
|
import id.web.ard.springbootwebfluxjjwt.entity.Message;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import reactor.core.publisher.Mono;
|
|
|
|
/**
|
|
*
|
|
* @author ardiansyah
|
|
*/
|
|
@RestController
|
|
public class ResourceREST {
|
|
|
|
@RequestMapping(value = "resource/user", method = RequestMethod.GET)
|
|
@PreAuthorize("hasRole('USER')")
|
|
public Mono<ResponseEntity<?>> user() {
|
|
return Mono.just(ResponseEntity.ok(new Message("Content for user")));
|
|
}
|
|
|
|
@RequestMapping(value = "resource/admin", method = RequestMethod.GET)
|
|
@PreAuthorize("hasRole('ADMIN')")
|
|
public Mono<ResponseEntity<?>> admin() {
|
|
return Mono.just(ResponseEntity.ok(new Message("Content for admin")));
|
|
}
|
|
|
|
@RequestMapping(value = "resource/user-or-admin", method = RequestMethod.GET)
|
|
@PreAuthorize("hasRole('USER') or hasRole('ADMIN')")
|
|
public Mono<ResponseEntity<?>> userOrAdmin() {
|
|
return Mono.just(ResponseEntity.ok(new Message("Content for user or admin")));
|
|
}
|
|
}
|