1. How
  2. How support response header manipulate

It’s very simple and doesn’t require any additional settings.

In your service implementation, you can set the desired response object, including the body and headers. It’s super easy to implement!

Implement

private static HttpCookie buildCookie(final String jwt){
  return
          ResponseCookie.from("Authorization",jwt)
                  .path("/")
                  .maxAge(Duration.ofDays(1))
                  .httpOnly(true).build();
}

@Override
public void login(
    final SimpleResultBuilder<LoginResponse> builder, final LoginRequest loginRequest) {
      //...
      builder.body().header(HttpHeaders.SET_COOKIE, buildCookie(jwt).toString());
      //....
}

As demo, we will set cookie in the HTTP response.

😆 Video Guide

  1. ApiHug101-Bilibili
  2. ApiHug101-Youtube