分用户的data

通过在key里加入header, cookie等等,可以将不同的用户数据存到相同的路劲。

  1. nuster rule r1 key method.scheme.host.uri.header_userId if { path /mypoint }
  2. nuster rule r2 key method.scheme.host.uri.cookie_sessionId if { path /mydata }

Set

  1. curl -v -X POST -d "333" -H "userId: 1000" http://127.0.0.1:8080/mypoint
  2. curl -v -X POST -d "555" -H "userId: 1001" http://127.0.0.1:8080/mypoint
  3. curl -v -X POST -d "userA data" --cookie "sessionId=ijsf023xe" http://127.0.0.1:8080/mydata
  4. curl -v -X POST -d "userB data" --cookie "sessionId=rosre329x" http://127.0.0.1:8080/mydata

Get

  1. curl -v http://127.0.0.1:8080/mypoint
  2. < 404 Not Found
  3. curl -v -H "userId: 1000" http://127.0.0.1:8080/mypoint
  4. < 200 OK
  5. 333
  6. curl -v --cookie "sessionId=ijsf023xe" http://127.0.0.1:8080/mydata
  7. < 200 OK
  8. userA data