Class DocServiceBuilder

java.lang.Object
com.linecorp.armeria.server.docs.DocServiceBuilder

public final class DocServiceBuilder
extends Object
Builds a new DocService.
  • Method Details

    • exampleHeaders

      public DocServiceBuilder exampleHeaders​(HttpHeaders... exampleHeaders)
      Adds the example HttpHeaders which are applicable to any services.
    • exampleHeaders

      public DocServiceBuilder exampleHeaders​(Iterable<? extends HttpHeaders> exampleHeaders)
      Adds the example HttpHeaders which are applicable to any services.
    • exampleHeaders

      public DocServiceBuilder exampleHeaders​(Class<?> serviceType, HttpHeaders... exampleHeaders)
      Adds the example HttpHeaders for the service with the specified type. This method is a shortcut to:
      
       exampleHeaders(serviceType.getName(), exampleHeaders);
       
    • exampleHeaders

      public DocServiceBuilder exampleHeaders​(Class<?> serviceType, Iterable<? extends HttpHeaders> exampleHeaders)
      Adds the example HttpHeaders for the service with the specified type. This method is a shortcut to:
      
       exampleHeaders(serviceType.getName(), exampleHeaders);
       
    • exampleHeaders

      public DocServiceBuilder exampleHeaders​(String serviceName, HttpHeaders... exampleHeaders)
      Adds the example HttpHeaders for the service with the specified name.
    • exampleHeaders

      public DocServiceBuilder exampleHeaders​(String serviceName, Iterable<? extends HttpHeaders> exampleHeaders)
      Adds the example HttpHeaders for the service with the specified name.
    • exampleHeaders

      public DocServiceBuilder exampleHeaders​(Class<?> serviceType, String methodName, HttpHeaders... exampleHeaders)
      Adds the example HttpHeaders for the method with the specified type and method name. This method is a shortcut to:
      
       exampleHeaders(serviceType.getName(), methodName, exampleHeaders);
       
    • exampleHeaders

      public DocServiceBuilder exampleHeaders​(Class<?> serviceType, String methodName, Iterable<? extends HttpHeaders> exampleHeaders)
      Adds the example HttpHeaders for the method with the specified type and method name. This method is a shortcut to:
      
       exampleHeaders(serviceType.getName(), methodName, exampleHeaders);
       
    • exampleHeaders

      public DocServiceBuilder exampleHeaders​(String serviceName, String methodName, HttpHeaders... exampleHeaders)
      Adds the example HttpHeaders for the method with the specified service and method name.
    • exampleHeaders

      public DocServiceBuilder exampleHeaders​(String serviceName, String methodName, Iterable<? extends HttpHeaders> exampleHeaders)
      Adds the example HttpHeaders for the method with the specified service and method name.
    • examplePaths

      public DocServiceBuilder examplePaths​(Class<?> serviceType, String methodName, String... paths)
      Adds the specified example paths for the method with the specified service and method name.
    • examplePaths

      public DocServiceBuilder examplePaths​(Class<?> serviceType, String methodName, Iterable<String> paths)
      Adds the specified example paths for the method with the specified service and method name.
    • examplePaths

      public DocServiceBuilder examplePaths​(String serviceName, String methodName, String... paths)
      Adds the specified example paths for the method with the specified service and method name.
    • examplePaths

      public DocServiceBuilder examplePaths​(String serviceName, String methodName, Iterable<String> paths)
      Adds the specified example paths for the method with the specified service and method name.
    • exampleQueries

      public DocServiceBuilder exampleQueries​(Class<?> serviceType, String methodName, String... queryStrings)
      Adds the specified example query strings for the method with the specified service and method name.
    • exampleQueries

      public DocServiceBuilder exampleQueries​(Class<?> serviceType, String methodName, Iterable<String> queryStrings)
      Adds the specified example query strings for the method with the specified service and method name.
    • exampleQueries

      public DocServiceBuilder exampleQueries​(String serviceName, String methodName, String... queryStrings)
      Adds the specified example query strings for the method with the specified service and method name.
    • exampleQueries

      public DocServiceBuilder exampleQueries​(String serviceName, String methodName, Iterable<String> queryStrings)
      Adds the specified example query strings for the method with the specified service and method name.
    • exampleRequests

      public DocServiceBuilder exampleRequests​(Class<?> serviceType, String methodName, Object... exampleRequests)
      Adds the example requests for the method with the specified service type and method name. This method is a shortcut to:
      
       exampleRequests(serviceType.getName(), methodName, exampleRequests);
       
    • exampleRequests

      public DocServiceBuilder exampleRequests​(Class<?> serviceType, String methodName, Iterable<?> exampleRequests)
      Adds the example requests for the method with the specified service type and method name. This method is a shortcut to:
      
       exampleRequests(serviceType.getName(), methodNane, exampleRequests);
       
    • exampleRequests

      public DocServiceBuilder exampleRequests​(String serviceName, String methodName, Object... exampleRequests)
      Adds the example requests for the method with the specified service and method name.
    • exampleRequests

      public DocServiceBuilder exampleRequests​(String serviceName, String methodName, Iterable<?> exampleRequests)
      Adds the example requests for the method with the specified service and method name.
    • exampleRequests

      public DocServiceBuilder exampleRequests​(Iterable<?> exampleRequests)
      Adds the example requests which are applicable to the method denoted by the specified example requests. Please note that this method may fail if the specified requests object do not provide the information about their service and method names.
      Throws:
      IllegalArgumentException - if failed to get the service and method name from an example request
    • include

      public DocServiceBuilder include​(DocServiceFilter filter)
      Adds the DocServiceFilter that checks whether a method will be included while building DocService. The DocServiceFilter will be invoked with the plugin, service and method name. The rule is as follows:

      Note that this can be called multiple times and the DocServiceFilters are composed using DocServiceFilter.or(DocServiceFilter) and DocServiceFilter.and(DocServiceFilter).

      See Also:
      exclude(DocServiceFilter), to find out how DocService generates documentaion
    • exclude

      public DocServiceBuilder exclude​(DocServiceFilter filter)
      Adds the DocServiceFilter that checks whether a method will be excluded while building DocService. The DocServiceFilter will be invoked with the plugin, service and method name. The rule is as follows:

      Note that this can be called multiple times and the DocServiceFilters are composed using DocServiceFilter.or(DocServiceFilter) and DocServiceFilter.and(DocServiceFilter).

      See Also:
      exclude(DocServiceFilter), to find out how DocService generates documentaion
    • injectedScripts

      public DocServiceBuilder injectedScripts​(String... scripts)
      Adds Javascript scripts to inject into the <head /> of the debug page HTML. This can be used to customize the debug page (e.g., to provide a HeaderProvider for enabling authentication based on local storage). All scripts are concatenated into the content of a single script tag.

      A common use case is to provide authentication of debug requests using a local storage access token, e.g.,

      
         armeria.registerHeaderProvider(function() {
           // Replace with fetching accesstoken using your favorite auth library.
           return Promise.resolve({ authorization: 'accesstoken' });
         });
       
    • injectedScripts

      public DocServiceBuilder injectedScripts​(Iterable<String> scripts)
      Adds Javascript scripts to inject into the <head /> of the debug page HTML. This can be used to customize the debug page (e.g., to provide a HeaderProvider for enabling authentication based on local storage). All scripts are concatenated into the content of a single script tag.

      A common use case is to provide authentication of debug requests using a local storage access token, e.g.,

      
         armeria.registerHeaderProvider(function() {
           // Replace with fetching accesstoken using your favorite auth library.
           return Promise.resolve({ authorization: 'accesstoken' });
         });
       
    • injectedScriptSupplier

      public DocServiceBuilder injectedScriptSupplier​(BiFunction<ServiceRequestContext,​HttpRequest,​String> supplier)
      Adds a supplier for Javascript scripts to inject into the <head /> of the debug page HTML. The supplier will be called every request for the initial DocService HTML. This can be used to customize the debug page per-request (e.g., to provide a HeaderProvider for enabling authentication based on an injected timestamped token). All scripts are concatenated into the content of a single script tag.
    • build

      public DocService build()
      Returns a newly-created DocService based on the properties of this builder.