Browsing and invoking services with DocService

DocService is a single-page web application which provides the following useful features:

  • Browsing the list of gRPC, Thrift or annotated services and their operations available in the server
  • Invoking a service operation from a web form
  • Creating a permalink for the invocation you've made

First, add DocService to the ServerBuilder:

import com.linecorp.armeria.common.grpc.GrpcSerializationFormats;
import com.linecorp.armeria.server.docs.DocService;
import com.linecorp.armeria.server.ServerBuilder;
import com.linecorp.armeria.server.thrift.THttpService;

ServerBuilder sb = Server.builder();
sb.http(8080);

// Add a Thrift service which implements 'ThriftHelloService'.
sb.service("/hello", THttpService.of(new MyThriftHelloService()));

// Add a gRPC service which implements 'GrpcHelloService'.
// Unlike Thrift, you must enable unframed requests explicitly.
sb.service(GrpcService.builder()
                      .addService(new MyGrpcHelloService())
                      .enableUnframedRequests(true)
                      .build());
// Add an annotated HTTP service.
sb.annotatedService("/service", new MyAnnotatedService());
// Add a DocService which scans all Thrift and gRPC services added to the server.
sb.serviceUnder("/docs", new DocService());
Server server = sb.build();
server.start().join();

Open http://127.0.0.1:8080/docs/ in your web browser and you'll see the following screen: