本文整理匯總了Java中org.restlet.Request.getMethod方法的典型用法代碼示例。如果您正苦於以下問題:Java Request.getMethod方法的具體用法?Java Request.getMethod怎麽用?Java Request.getMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.restlet.Request
的用法示例。
在下文中一共展示了Request.getMethod方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: authorize
import org.restlet.Request; //導入方法依賴的package包/類
@Override
protected boolean authorize(Request request, Response response) {
if (request.getMethod() == Method.OPTIONS) return true;
if (request.getAttributes().get("account") != null) return true;
String accessToken = request.getHeaders().getFirstValue(HttpHeaders.AUTHORIZATION);
if (accessToken == null) return true;
try {
accessToken.replace("OAuth ", "");
AccountBean acc = mAccounts.getAccountFromToken(accessToken);
if (acc != null) {
request.getAttributes().put("account", acc);
return true;
}
} catch (Exception e) {
Main.LOGGER.log(Level.WARNING, "Error while handling OAuth authentification", e);
return false;
}
return false;
}
示例2: verify
import org.restlet.Request; //導入方法依賴的package包/類
@Override
public int verify(Request request, Response response) {
if (request.getMethod() == Method.OPTIONS) return RESULT_VALID;
if (request.getAttributes().get("account") != null) return RESULT_VALID;
String accessToken = request.getHeaders().getFirstValue(HttpHeaders.AUTHORIZATION);
if (accessToken == null) return RESULT_MISSING;
try {
accessToken.replace("OAuth ", "");
AccountBean acc = mAccounts.getAccountFromToken(accessToken);
if (acc != null) {
request.getAttributes().put("account", acc);
return RESULT_VALID;
}
} catch (Exception e) {
Main.LOGGER.log(Level.WARNING, "Error while handling OAuth authentification", e);
return RESULT_INVALID;
}
return RESULT_INVALID;
}
示例3: handle
import org.restlet.Request; //導入方法依賴的package包/類
@Override
public void handle(Request request, Response response) {
Method method = request.getMethod();
LOG.debug("MethodRouter ({}) received request method: {}", uriPattern, method);
Restlet target = routes.get(method);
if (target != null) {
target.handle(request, response);
} else {
LOG.debug("MethodRouter ({}) method not allowed: {}", uriPattern, method);
response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
// must include list of allowed methods
response.setAllowedMethods(routes.keySet());
}
}
示例4: handle
import org.restlet.Request; //導入方法依賴的package包/類
@Override
public void handle( Request request, Response response )
{
try
{
super.handle( request, response );
Method method = request.getMethod();
if( method.equals( Method.GET ) )
{
get( request, response );
}
if( method.equals( Method.DELETE ) )
{
delete( request, response );
}
if( method.equals( Method.POST ) )
{
post( request, response );
}
if( method.equals( Method.PUT ) )
{
put( request, response );
}
}
catch( RuntimeException e )
{
e.printStackTrace();
throw e;
}
}
示例5: authorize
import org.restlet.Request; //導入方法依賴的package包/類
@Override
protected boolean authorize(Request request, Response response) {
if (request.getMethod() == Method.OPTIONS) return true;
AccountBean bean = (AccountBean) request.getAttributes().get("account");
return bean.getGrade() >= mMinimalGrade;
}