title: How to get username from mono<user> on spring boot webflux?
body: <p>I try to make handler and router classes of spring boot webflux. The model class is user class. Codes are</p>
  
  <pre><code>@Getter
  @Setter
  @AllArgsConstructor
  @NoArgsConstructor
  @Document(collection="Users") 
  public class User {
  
      @Id 
      private String _id;
  
      @Indexed(unique = true) 
      private Long id; 
  
      @Indexed(unique=true)  
      private String username;
  
      private String password;
  
      private String email;
  
      private String fullname;
  
      private String role;
  }
  </code></pre>
  
  <p>And below is the handler class of webflux project. In register method, I make the id duplication test codes. But It is totally WRONG.</p>
  
  <pre><code>@Component
  public class UserHandler {
  
      @Autowired
      private UserReactiveMongoRepository userRepository;
  
      public Mono&lt;ServerResponse&gt; register(ServerRequest request) {
          Mono&lt;User&gt; monoUser = request.bodyToMono(User.class);
          String id = monoUser.map(u -&gt; u.get_id()).toString();
  
          if(userRepository.existsById(id) == null)
              return ServerResponse.ok().build(userRepository.insert(monoUser));
  
          return ServerResponse.ok().build();
      }
  }
  </code></pre>
  
  <p>I want to extract the username or id string from Mono of spring webflux.
  Any comments will be needed. I am stuck with this part.</p>