-
Notifications
You must be signed in to change notification settings - Fork 927
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Motivation: A user might want to specify multiple paths for annotated http services. Modification: - Allow repeatable annotations for `@Path` annotation. - Different behavior in path declaration (described below) - One `AnnotatedHttpService` is created for each `(httpMethod, pathMapping)` - It is difficult to accommodate multiple pathMappings using a single `AnnotatedHttpService` because `AnnotatedValueResolver` may be different - It may be possible to optimize this by serving multiple `httpMethod`s that have the same `pathMapping` using a single `AnnotatedHttpService` at the cost of code complexiy - Merge `MethodInfo` endpoints with same (`httpMethod`, `methodName`) - Known issue: overloaded methods for `AnnotatedHttpService` are not displayed in docs. I'm thinking this can be tackled in a separate PR. #### Breaking change in path declaration behavior **AS-IS** ``` @get("/") @post public void method1() {} // accepts both Get("/") and Post("/") ``` **TO-BE** ``` @get("/") @post public void method1() {} // exception thrown. Path declared for Get not applied to Post ```
- Loading branch information
Showing
13 changed files
with
733 additions
and
167 deletions.
There are no files selected for viewing
274 changes: 160 additions & 114 deletions
274
core/src/main/java/com/linecorp/armeria/internal/annotation/AnnotatedHttpServiceFactory.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
34 changes: 34 additions & 0 deletions
34
core/src/main/java/com/linecorp/armeria/server/annotation/Paths.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,34 @@ | ||
/* | ||
* Copyright 2019 LINE Corporation | ||
* | ||
* LINE Corporation 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: | ||
* | ||
* https://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 com.linecorp.armeria.server.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* The containing annotation type for {@link Path}. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.METHOD) | ||
public @interface Paths { | ||
/** | ||
* An array of {@link Path}s. | ||
*/ | ||
Path[] value(); | ||
} |
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.