-
Notifications
You must be signed in to change notification settings - Fork 71
Add sse payload validation #1092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Add sse payload validation
- Loading branch information
commit 72b891e68d39cfe889ee3be71dfebce44015a394
There are no files selected for viewing
This file contains hidden or 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
86 changes: 86 additions & 0 deletions
86
...e/src/main/java/io/aklivity/zilla/runtime/binding/sse/config/SseOptionsConfigBuilder.java
This file contains hidden or 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,86 @@ | ||
| /* | ||
| * Copyright 2021-2023 Aklivity Inc. | ||
| * | ||
| * Aklivity licenses this file to you under the Apache License, | ||
| * version 2.0 (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.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| * License for the specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package io.aklivity.zilla.runtime.binding.sse.config; | ||
|
|
||
| import java.util.LinkedList; | ||
| import java.util.List; | ||
| import java.util.function.Function; | ||
|
|
||
| import io.aklivity.zilla.runtime.engine.config.ConfigBuilder; | ||
| import io.aklivity.zilla.runtime.engine.config.OptionsConfig; | ||
|
|
||
| public class SseOptionsConfigBuilder<T> extends ConfigBuilder<T, SseOptionsConfigBuilder<T>> | ||
| { | ||
| private final Function<OptionsConfig, T> mapper; | ||
|
|
||
| private int retry; | ||
| private List<SsePathConfig> paths; | ||
|
|
||
| SseOptionsConfigBuilder( | ||
| Function<OptionsConfig, T> mapper) | ||
| { | ||
| this.mapper = mapper; | ||
| } | ||
|
|
||
| @Override | ||
| @SuppressWarnings("unchecked") | ||
| protected Class<SseOptionsConfigBuilder<T>> thisType() | ||
| { | ||
| return (Class<SseOptionsConfigBuilder<T>>) getClass(); | ||
| } | ||
|
|
||
| public SseOptionsConfigBuilder<T> retry( | ||
| int retry) | ||
| { | ||
|
|
||
| this.retry = retry; | ||
| return this; | ||
| } | ||
|
|
||
| public SseOptionsConfigBuilder<T> paths( | ||
| List<SsePathConfig> paths) | ||
| { | ||
| if (paths == null) | ||
| { | ||
| paths = new LinkedList<>(); | ||
| } | ||
| this.paths = paths; | ||
| return this; | ||
| } | ||
|
|
||
| public SseOptionsConfigBuilder<T> path( | ||
| SsePathConfig path) | ||
| { | ||
| if (this.paths == null) | ||
| { | ||
| this.paths = new LinkedList<>(); | ||
| } | ||
| this.paths.add(path); | ||
| return this; | ||
| } | ||
|
|
||
| public SsePathConfigBuilder<SseOptionsConfigBuilder<T>> path() | ||
| { | ||
| return new SsePathConfigBuilder<>(this::path); | ||
| } | ||
|
|
||
| @Override | ||
| public T build() | ||
| { | ||
| return mapper.apply(new SseOptionsConfig(retry, paths)); | ||
| } | ||
|
|
||
| } |
40 changes: 40 additions & 0 deletions
40
...binding-sse/src/main/java/io/aklivity/zilla/runtime/binding/sse/config/SsePathConfig.java
This file contains hidden or 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,40 @@ | ||
| /* | ||
| * Copyright 2021-2023 Aklivity Inc. | ||
| * | ||
| * Aklivity licenses this file to you under the Apache License, | ||
| * version 2.0 (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.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| * License for the specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package io.aklivity.zilla.runtime.binding.sse.config; | ||
|
|
||
| import static java.util.function.Function.identity; | ||
|
|
||
| import io.aklivity.zilla.runtime.engine.config.ModelConfig; | ||
|
|
||
| public class SsePathConfig | ||
| { | ||
| public final String path; | ||
| public final ModelConfig content; | ||
|
|
||
|
|
||
| SsePathConfig( | ||
| String path, | ||
| ModelConfig content) | ||
| { | ||
| this.path = path; | ||
| this.content = content; | ||
| } | ||
|
|
||
| public static SsePathConfigBuilder<SsePathConfig> builder() | ||
| { | ||
| return new SsePathConfigBuilder<>(identity()); | ||
| } | ||
| } | ||
68 changes: 68 additions & 0 deletions
68
...-sse/src/main/java/io/aklivity/zilla/runtime/binding/sse/config/SsePathConfigBuilder.java
This file contains hidden or 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,68 @@ | ||
| /* | ||
| * Copyright 2021-2023 Aklivity Inc. | ||
| * | ||
| * Aklivity licenses this file to you under the Apache License, | ||
| * version 2.0 (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.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| * License for the specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package io.aklivity.zilla.runtime.binding.sse.config; | ||
|
|
||
| import java.util.function.Function; | ||
|
|
||
| import io.aklivity.zilla.runtime.engine.config.ConfigBuilder; | ||
| import io.aklivity.zilla.runtime.engine.config.ModelConfig; | ||
|
|
||
| public class SsePathConfigBuilder<T> extends ConfigBuilder<T, SsePathConfigBuilder<T>> | ||
| { | ||
| private final Function<SsePathConfig, T> mapper; | ||
|
|
||
| private String path; | ||
| private ModelConfig content; | ||
|
|
||
| SsePathConfigBuilder( | ||
| Function<SsePathConfig, T> mapper) | ||
| { | ||
| this.mapper = mapper; | ||
| } | ||
|
|
||
| @Override | ||
| @SuppressWarnings("unchecked") | ||
| protected Class<SsePathConfigBuilder<T>> thisType() | ||
| { | ||
| return (Class<SsePathConfigBuilder<T>>) getClass(); | ||
| } | ||
|
|
||
| public SsePathConfigBuilder<T> path( | ||
| String path) | ||
| { | ||
| this.path = path; | ||
| return this; | ||
| } | ||
|
|
||
| public SsePathConfigBuilder<T> content( | ||
| ModelConfig content) | ||
| { | ||
| this.content = content; | ||
| return this; | ||
| } | ||
|
|
||
| public <C extends ConfigBuilder<SsePathConfigBuilder<T>, C>> C content( | ||
| Function<Function<ModelConfig, SsePathConfigBuilder<T>>, C> content) | ||
| { | ||
| return content.apply(this::content); | ||
| } | ||
|
|
||
| @Override | ||
| public T build() | ||
| { | ||
| return mapper.apply(new SsePathConfig(path, content)); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.