-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds the ability have internal endpoints listen on ksql.interna…
…l.listener (#5212) * feat: Adds the ability have internal endpoints listen on ksql.internal.listener
- Loading branch information
1 parent
1ad497c
commit 46acb73
Showing
17 changed files
with
653 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
ksqldb-rest-app/src/main/java/io/confluent/ksql/api/server/InternalEndpointHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2020 Confluent Inc. | ||
* | ||
* Licensed under the Confluent Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at | ||
* | ||
* http://www.confluent.io/confluent-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package io.confluent.ksql.api.server; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import io.netty.handler.codec.http.HttpResponseStatus; | ||
import io.vertx.core.Handler; | ||
import io.vertx.ext.web.RoutingContext; | ||
import java.util.Set; | ||
|
||
public class InternalEndpointHandler implements Handler<RoutingContext> { | ||
private static final Set<String> INTERNAL_PATHS = ImmutableSet.of( | ||
"/heartbeat", "/lag"); | ||
|
||
private final boolean isFromInternalListener; | ||
|
||
public InternalEndpointHandler(final boolean isFromInternalListener) { | ||
this.isFromInternalListener = isFromInternalListener; | ||
} | ||
|
||
|
||
@Override | ||
public void handle(final RoutingContext routingContext) { | ||
if (INTERNAL_PATHS.contains(routingContext.normalisedPath()) | ||
&& !isFromInternalListener) { | ||
routingContext.fail(HttpResponseStatus.BAD_REQUEST.code(), | ||
new KsqlApiException("Can't call internal endpoint on public listener", | ||
ErrorCodes.ERROR_CODE_INTERNAL_ONLY)); | ||
} else { | ||
routingContext.next(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.