Search in sources :

Example 1 with RestServiceImpl

use of com.alipay.sofa.rpc.rest.RestServiceImpl in project sofa-rpc by sofastack.

the class RestServerMain method main.

public static void main(String[] args) {
    ApplicationConfig application = new ApplicationConfig().setAppName("test-server");
    /*
         访问地址:
         POST http://127.0.0.1:8888/rest/hello/code/name
         GET http://127.0.0.1:8888/rest/hello/code
         PUT http://127.0.0.1:8888/rest/hello/code/name
         DELETE http://127.0.0.1:8888/rest/hello/code
         GET http://127.0.0.1:8888/rest/get/1234567890
         POST http://127.0.0.1:8888/rest/post/1234567890 bodydddddd
         */
    ServerConfig serverConfig = new ServerConfig().setProtocol("rest").setPort(8888).setDaemon(false);
    ProviderConfig<RestService> providerConfig = new ProviderConfig<RestService>().setInterfaceId(RestService.class.getName()).setApplication(application).setRef(new RestServiceImpl()).setBootstrap("rest").setServer(serverConfig).setRegister(false);
    providerConfig.export();
    LOGGER.warn("started at pid {}", RpcRuntimeContext.PID);
}
Also used : ServerConfig(com.alipay.sofa.rpc.config.ServerConfig) ApplicationConfig(com.alipay.sofa.rpc.config.ApplicationConfig) ProviderConfig(com.alipay.sofa.rpc.config.ProviderConfig) RestServiceImpl(com.alipay.sofa.rpc.rest.RestServiceImpl) RestService(com.alipay.sofa.rpc.rest.RestService)

Aggregations

ApplicationConfig (com.alipay.sofa.rpc.config.ApplicationConfig)1 ProviderConfig (com.alipay.sofa.rpc.config.ProviderConfig)1 ServerConfig (com.alipay.sofa.rpc.config.ServerConfig)1 RestService (com.alipay.sofa.rpc.rest.RestService)1 RestServiceImpl (com.alipay.sofa.rpc.rest.RestServiceImpl)1