forked from caelum/vraptor
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support to options http verb in the controller resources through of O…
…ptions annotation
- Loading branch information
1 parent
1612b8f
commit 8b0abb3
Showing
5 changed files
with
57 additions
and
9 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
vraptor-core/src/main/java/br/com/caelum/vraptor/Options.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,36 @@ | ||
/*** | ||
* Copyright (c) 2009 Caelum - www.caelum.com.br/opensource | ||
* All rights reserved. | ||
* | ||
* Licensed 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 br.com.caelum.vraptor; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Supports the OPTIONS http method. | ||
* | ||
* @author Douglas Rodrigo Ferreira | ||
*/ | ||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Options { | ||
} | ||
This comment has been minimized.
Sorry, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,9 +38,7 @@ public void deny(RequestInfo request, Set<HttpMethod> allowedMethods) { | |
request.getResponse().addHeader( | ||
"Allow", allowedMethods.toString().replaceAll("\\[|\\]", "")); | ||
try { | ||
if (!"OPTIONS".equalsIgnoreCase(request.getRequest().getMethod())) { | ||
request.getResponse().sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); | ||
} | ||
request.getResponse().sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); | ||
This comment has been minimized.
Sorry, something went wrong.
lucascs
|
||
} catch (IOException e) { | ||
throw new InterceptionException(e); | ||
} | ||
|
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
1 comment
on commit 8b0abb3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @lucascs thanks for the tips, I'm already changing the code following your observations.
Following the other annotations, this one should also accept a path attribute.