title: webflux how to pass current login Mono string to a flux
body: <p>I am still new to Spring boot Webflux. I am using Casssandra as my database, below i have a friends tables, i want to get all my friends based on my login ID. How can i get the current login ID and pass the ID to a flux</p>
  
  <pre><code>// Here i retrieved currently login user ID which is a mono string
  
  public Mono&lt;String&gt; getUserID(Mono&lt;String&gt; principal) {
    return principal
     .map(Principal::getName)
  }
  </code></pre>
  
  <p>OR </p>
  
  <pre><code>public static Mono&lt;String&gt; getUserIDFromRequest(ServerRequest request) {
      return request.principal()
              .cast(UsernamePasswordAuthenticationToken.class)
              .map(UsernamePasswordAuthenticationToken::getName);
  }
  
  // My friends table
  
  public class Friends {
    @PrimaryKey("userid")
    private long userId;
    private long friendId;
    private FriendObject friendObject;
    private String since;
    private boolean enableNotifications;
    private boolean allowMessages;
    // Getters and setters
  }
  
  @Repository
  public interface FriendsRepository extends ReactiveCassandraRepository&lt;Friends, Long&gt; {
  }
  
  @Service
  public class FriendshipServiceImpl implements FriendshipService {
    @Override
    public Mono&lt;Friends&gt; addFriend(Friends friends) {
      return friendsRepository.save(friends);
    }
  }
  
  public class FriendshipHandler {
  
    // How to pass the Login Mono&lt;String&gt; to this flux Or how can i combine Mono and Flux?
    @GetMapping(path="/friends/list", produces=MediaType.TEXT_EVENT_STREAM_VALUE)
    Flux&lt;Friends&gt; getFriends(Mono&lt;Principal&gt; principal) {
      return friendshipService.getFriends(Long.valueOf("The login ID"));
    }
  
    OR
  
    public Mono&lt;ServerResponse&gt; getFriends(ServerRequest request) {
       return ok().body(
        friendshipService
          .getFriends(Long.valueOf("The login ID")), Friends.class);
    }
  }
  </code></pre>