tree: 78a9f64cf95c2271e91acce8ed49e90e4663aa86 [path history] [tgz]
  1. src/
  2. case-configuration.yml
  3. case-versions.conf
  4. pom.xml
  5. README.md
2-advanced/dubbo-samples-triple-rest/dubbo-samples-triple-rest-basic/README.md

Dubbo Triple Rest Basic Example

This example shows how to export rest API using the built-in annotation in triple protocol.

How to run

Step into ‘dubbo-samples-triple-rest-basic’ directory then, run the following command to start application:

mvn spring-boot:run

Run the following command to see server works as expected:

# Passing parameter via query string
curl -i 'http://localhost:50052/org.apache.dubbo.rest.demo.DemoService/hello?name=world'
# Expected output: "Hello world"
# With double quotes because the default output content-type is 'application/json'

# Passing parameter via body
curl -i -H 'content-type: application/json' -d '{"title":"Mr","name":"Yang"}' 'http://localhost:50052/org.apache.dubbo.rest.demo.DemoService/helloUser'
# Expected output: "Hello Mr. Yang"

# Multiple ways to pass parameters
curl -i -H "c: 3" -d 'name=Yang' "http://localhost:50052/org.apache.dubbo.rest.demo.DemoService/hi.txt?title=Mr"
# Expected output: Hello Mr. Yang, 3
# No double quotes because we specify the output content-type is 'text/plain' by suffixing '.txt'

Or, you can visit the following link by using web browser: http://localhost:50052/demo/hello?name=world