Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.springframework.cloud.gateway.server.mvc.common.MvcUtils;
import org.springframework.cloud.gateway.server.mvc.filter.FilterBeanFactoryDiscoverer;
import org.springframework.cloud.gateway.server.mvc.filter.FilterDiscoverer;
import org.springframework.cloud.gateway.server.mvc.handler.GatewayServerResponse;
import org.springframework.cloud.gateway.server.mvc.handler.HandlerDiscoverer;
import org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctionDefinition;
import org.springframework.cloud.gateway.server.mvc.invoke.InvocationContext;
Expand Down Expand Up @@ -101,7 +102,7 @@ public String toString() {
};

private static final RouterFunction<ServerResponse> NEVER_ROUTE = RouterFunctions.route(neverPredicate,
request -> ServerResponse.notFound().build());
request -> GatewayServerResponse.notFound().build());

private final Log log = LogFactory.getLog(getClass());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.jspecify.annotations.Nullable;

import org.springframework.cloud.gateway.server.mvc.common.MvcUtils;
import org.springframework.cloud.gateway.server.mvc.handler.GatewayServerResponse;
import org.springframework.core.task.TaskExecutor;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
Expand Down Expand Up @@ -78,7 +79,7 @@ public static HandlerFilterFunction<ServerResponse, ServerResponse> rateLimit(
String key = config.getKeyResolver() != null ? config.getKeyResolver().apply(request) : "";
if (!StringUtils.hasText(key)) {
// TODO: configurable empty key status code
return ServerResponse.status(HttpStatus.FORBIDDEN).build();
return GatewayServerResponse.status(HttpStatus.FORBIDDEN).build();
}
TaskExecutor taskExecutor = MvcUtils.getApplicationContext(request)
.getBean(APPLICATION_TASK_EXECUTOR_BEAN_NAME, TaskExecutor.class);
Expand All @@ -100,7 +101,7 @@ public static HandlerFilterFunction<ServerResponse, ServerResponse> rateLimit(
serverResponse.headers().add(config.getHeaderName(), String.valueOf(remainingTokens));
return serverResponse;
}
return ServerResponse.status(config.getStatusCode())
return GatewayServerResponse.status(config.getStatusCode())
.header(config.getHeaderName(), String.valueOf(remainingTokens))
.build();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static HandlerFilterFunction<ServerResponse, ServerResponse> circuitBreak
}
// if resume without error, return ok response
if (config.isResumeWithoutError()) {
return ServerResponse.ok().build();
return GatewayServerResponse.ok().build();
}
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR,
throwable != null ? throwable.getMessage() : null, throwable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.springframework.cloud.gateway.server.mvc.common.Shortcut;
import org.springframework.cloud.gateway.server.mvc.filter.AfterFilterFunctions.DedupeStrategy;
import org.springframework.cloud.gateway.server.mvc.filter.BeforeFilterFunctions.FallbackHeadersConfig;
import org.springframework.cloud.gateway.server.mvc.handler.GatewayServerResponse;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatusCode;
import org.springframework.util.Assert;
Expand Down Expand Up @@ -129,8 +130,9 @@ static HandlerFilterFunction<ServerResponse, ServerResponse> redirectTo(HttpStat
static HandlerFilterFunction<ServerResponse, ServerResponse> redirectTo(HttpStatusHolder status, URI uri) {
Assert.isTrue(status.is3xxRedirection(), "status must be a 3xx code, but was " + status);

return (request,
next) -> ServerResponse.status(status.resolve()).header(HttpHeaders.LOCATION, uri.toString()).build();
return (request, next) -> GatewayServerResponse.status(status.resolve())
.header(HttpHeaders.LOCATION, uri.toString())
.build();
}

@Shortcut
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static ServerResponse processRequest(ServerRequest request, @Nullable FunctionIn
}

if (function == null) {
return ServerResponse.notFound().build();
return GatewayServerResponse.notFound().build();
}

HttpHeaders headers = request.headers().asHttpHeaders();
Expand All @@ -95,13 +95,13 @@ static ServerResponse processRequest(ServerRequest request, @Nullable FunctionIn
}
Object result = function.apply(inputMessage);
if (function.isConsumer()) {
return HttpMethod.DELETE.equals(request.method()) ? ServerResponse.ok().build()
: ServerResponse.accepted()
return HttpMethod.DELETE.equals(request.method()) ? GatewayServerResponse.ok().build()
: GatewayServerResponse.accepted()
.headers(h -> h.addAll(sanitize(headers, ignoredHeaders, requestOnlyHeaders)))
.build();
}

BodyBuilder responseOkBuilder = ServerResponse.ok()
BodyBuilder responseOkBuilder = GatewayServerResponse.ok()
.headers(h -> h.addAll(sanitize(headers, ignoredHeaders, requestOnlyHeaders)));
if (result instanceof Iterable i) {
List aggregatedResult = (List) StreamSupport.stream(i.spliterator(), false).map(m -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static HandlerFunction<ServerResponse> fn(String functionName) {
return processRequest(request, function, body, false, Collections.emptyList(), Collections.emptyList(),
additionalRequestHeaders);
}
return ServerResponse.notFound().build();
return GatewayServerResponse.notFound().build();
};
}

Expand All @@ -111,9 +111,9 @@ public static HandlerFunction<ServerResponse> stream(String bindingName) {
.fromHttp(FunctionHandlerHeaderUtils.sanitize(request.headers().asHttpHeaders()));
boolean send = streamOps.send(expandedBindingName, MessageBuilder.createMessage(body, messageHeaders));
if (send) {
return ServerResponse.accepted().build();
return GatewayServerResponse.accepted().build();
}
return ServerResponse.badRequest().build();
return GatewayServerResponse.badRequest().build();
};
}

Expand Down
Loading
Loading