Skip to content

Commit

Permalink
♻️ refactor: 优化了 SessionConfiguration.java 和 R2dbcConfiguration.java …
Browse files Browse the repository at this point in the history
…文件格式。
  • Loading branch information
vnobo committed May 29, 2024
1 parent 6a12eae commit e68eb8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.springframework.data.domain.ReactiveAuditorAware;
import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration;
import org.springframework.data.r2dbc.config.EnableR2dbcAuditing;
import org.springframework.lang.NonNull;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.List;
Expand All @@ -28,15 +27,13 @@ public class R2dbcConfiguration extends AbstractR2dbcConfiguration {

private final List<Converter<?, ?>> customConverters;

@NonNull
@Override
public ConnectionFactory connectionFactory() {
public @lombok.NonNull ConnectionFactory connectionFactory() {
return ConnectionFactories.get("r2dbc:..");
}

@NonNull
@Override
public List<Object> getCustomConverters() {
public @lombok.NonNull List<Object> getCustomConverters() {
return Lists.newArrayList(customConverters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class SessionConfiguration {
public static final String HEADER_SESSION_ID_NAME = "X-Auth-Token";
public static final String X_REQUESTED_WITH = "X-Requested-With";
public static final String XML_HTTP_REQUEST = "XMLHttpRequest";
public static final Pattern AUTHORIZATION_PATTERN = Pattern.compile(
"^Bearer (?<token>[a-zA-Z0-9-._~+/]+=*)$", Pattern.CASE_INSENSITIVE);

@Bean
@Primary
Expand All @@ -48,8 +50,6 @@ public WebSessionIdResolver webSessionIdResolver() {
}

static class CustomWebSessionIdResolver extends HeaderWebSessionIdResolver {
private static final Pattern AUTHORIZATION_PATTERN = Pattern.compile("^Bearer (?<token>[a-zA-Z0-9-._~+/]+=*)$",
Pattern.CASE_INSENSITIVE);

private final CookieWebSessionIdResolver cookieWebSessionIdResolver = new CookieWebSessionIdResolver();

Expand All @@ -62,9 +62,8 @@ public void setSessionId(@NonNull ServerWebExchange exchange, @NonNull String id
}
}

@NonNull
@Override
public List<String> resolveSessionIds(@NonNull ServerWebExchange exchange) {
public @NonNull List<String> resolveSessionIds(@NonNull ServerWebExchange exchange) {
List<String> requestedWith;
HttpHeaders httpHeaders = exchange.getRequest().getHeaders();
if (XML_HTTP_REQUEST.equalsIgnoreCase(httpHeaders.getFirst(X_REQUESTED_WITH))) {
Expand Down

0 comments on commit e68eb8f

Please sign in to comment.