2016-05-13 29 views
0

我設計了我的API來接受access_token查詢參數,只有少數端點(如/login)除外。有沒有辦法像這樣寫一個RAML規則?RAML全局查詢參數(少數路由除外)

/login: 
    description: hello world 
    post: 
/hello: 
    description: hello world 
    get: 
    queryParameters: 
     access_token: 
/world: 
    description: hello world 
    get: 
    queryParameters: 
     access_token: 

回答

0

你可以使用這個特質。示例

traits: 
    - withAccessToken: 
    queryParameters: 
     access_token: 
/login: 
    description: hello world 
    post: 
/hello: 
    description: hello world 
    get: 
    is: [withAccessToken] 
/world: 
    description: hello world 
    get: 
    is: [withAccessToken] 

但是,對access_token使用查詢不是安全性。爲此更好地使用標題。