當前位置: 首頁>>代碼示例>>Java>>正文


Java Request.getMethod方法代碼示例

本文整理匯總了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;
}
 
開發者ID:FightForSub,項目名稱:FFS-Api,代碼行數:24,代碼來源:AuthAggregator.java

示例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;
}
 
開發者ID:FightForSub,項目名稱:FFS-Api,代碼行數:24,代碼來源:OAuthVerifier.java

示例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());
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:16,代碼來源:MethodBasedRouter.java

示例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;
    }
}
 
開發者ID:apache,項目名稱:polygene-java,代碼行數:31,代碼來源:PolygeneEntityRestlet.java

示例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;
}
 
開發者ID:FightForSub,項目名稱:FFS-Api,代碼行數:7,代碼來源:GroupAuthorizer.java


注:本文中的org.restlet.Request.getMethod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。