-
Notifications
You must be signed in to change notification settings - Fork 65
Ftr: add extension module #181
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
941e176
Ftr: add extension module
onewe b65c452
cargo fmt all
onewe 9772d2a
fix ci error
onewe 6d281e3
fix nacos image version error
onewe c4d3144
Rft: re-design extension register
onewe ca82644
Fix: cargo fix
onewe 49426e3
Fix: add some license for every files
onewe ad375e5
Fix: fmt all
onewe 6c3db1f
Fix: Add license for extension_param.rs and registry_param.rs
onewe be599c2
Fix: rename query_param_by_kv method name
onewe 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
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
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 |
---|---|---|
|
@@ -58,6 +58,7 @@ serde_yaml = "0.9.4" # yaml file parser | |
once_cell = "1.16.0" | ||
itertools = "0.10.1" | ||
bytes = "1.0" | ||
url = "2.5.0" | ||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF 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. | ||
*/ | ||
use crate::{url::UrlParam, StdError}; | ||
use std::{borrow::Cow, convert::Infallible, str::FromStr}; | ||
|
||
pub struct ExtensionName(String); | ||
|
||
impl ExtensionName { | ||
pub fn new(name: String) -> Self { | ||
ExtensionName(name) | ||
} | ||
} | ||
|
||
impl UrlParam for ExtensionName { | ||
type TargetType = String; | ||
|
||
fn name() -> &'static str { | ||
"extension-name" | ||
} | ||
|
||
fn value(&self) -> Self::TargetType { | ||
self.0.clone() | ||
} | ||
|
||
fn as_str(&self) -> Cow<str> { | ||
self.0.as_str().into() | ||
} | ||
} | ||
|
||
impl FromStr for ExtensionName { | ||
type Err = StdError; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
Ok(ExtensionName::new(s.to_string())) | ||
} | ||
} | ||
|
||
pub enum ExtensionType { | ||
Registry, | ||
} | ||
|
||
impl UrlParam for ExtensionType { | ||
type TargetType = String; | ||
|
||
fn name() -> &'static str { | ||
"extension-type" | ||
} | ||
|
||
fn value(&self) -> Self::TargetType { | ||
match self { | ||
ExtensionType::Registry => "registry".to_owned(), | ||
} | ||
} | ||
|
||
fn as_str(&self) -> Cow<str> { | ||
match self { | ||
ExtensionType::Registry => Cow::Borrowed("registry"), | ||
} | ||
} | ||
} | ||
|
||
impl FromStr for ExtensionType { | ||
type Err = Infallible; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
match s { | ||
"registry" => Ok(ExtensionType::Registry), | ||
_ => panic!("the extension type enum is not in range"), | ||
} | ||
} | ||
} |
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.