Package com.linecorp.armeria.server.docs
Class DocServiceBuilder
java.lang.Object
com.linecorp.armeria.server.docs.DocServiceBuilder
public final class DocServiceBuilder extends Object
Builds a new
DocService
.-
Method Summary
Modifier and Type Method Description DocService
build()
Returns a newly-createdDocService
based on the properties of this builder.DocServiceBuilder
exampleHeaders(HttpHeaders... exampleHeaders)
Adds the exampleHttpHeaders
which are applicable to any services.DocServiceBuilder
exampleHeaders(Class<?> serviceType, HttpHeaders... exampleHeaders)
Adds the exampleHttpHeaders
for the service with the specified type.DocServiceBuilder
exampleHeaders(Class<?> serviceType, Iterable<? extends HttpHeaders> exampleHeaders)
Adds the exampleHttpHeaders
for the service with the specified type.DocServiceBuilder
exampleHeaders(Class<?> serviceType, String methodName, HttpHeaders... exampleHeaders)
Adds the exampleHttpHeaders
for the method with the specified type and method name.DocServiceBuilder
exampleHeaders(Class<?> serviceType, String methodName, Iterable<? extends HttpHeaders> exampleHeaders)
Adds the exampleHttpHeaders
for the method with the specified type and method name.DocServiceBuilder
exampleHeaders(Iterable<? extends HttpHeaders> exampleHeaders)
Adds the exampleHttpHeaders
which are applicable to any services.DocServiceBuilder
exampleHeaders(String serviceName, HttpHeaders... exampleHeaders)
Adds the exampleHttpHeaders
for the service with the specified name.DocServiceBuilder
exampleHeaders(String serviceName, Iterable<? extends HttpHeaders> exampleHeaders)
Adds the exampleHttpHeaders
for the service with the specified name.DocServiceBuilder
exampleHeaders(String serviceName, String methodName, HttpHeaders... exampleHeaders)
Adds the exampleHttpHeaders
for the method with the specified service and method name.DocServiceBuilder
exampleHeaders(String serviceName, String methodName, Iterable<? extends HttpHeaders> exampleHeaders)
Adds the exampleHttpHeaders
for the method with the specified service and method name.DocServiceBuilder
examplePaths(Class<?> serviceType, String methodName, Iterable<String> paths)
Adds the specified example paths for the method with the specified service and method name.DocServiceBuilder
examplePaths(Class<?> serviceType, String methodName, String... paths)
Adds the specified example paths for the method with the specified service and method name.DocServiceBuilder
examplePaths(String serviceName, String methodName, Iterable<String> paths)
Adds the specified example paths for the method with the specified service and method name.DocServiceBuilder
examplePaths(String serviceName, String methodName, String... paths)
Adds the specified example paths for the method with the specified service and method name.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.DocServiceBuilder
exampleQueries(Class<?> serviceType, String methodName, String... queryStrings)
Adds the specified example query strings for the method with the specified service and method name.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.DocServiceBuilder
exampleQueries(String serviceName, String methodName, String... queryStrings)
Adds the specified example query strings for the method with the specified service and method name.DocServiceBuilder
exampleRequests(Class<?> serviceType, String methodName, Iterable<?> exampleRequests)
Adds the example requests for the method with the specified service type and method name.DocServiceBuilder
exampleRequests(Class<?> serviceType, String methodName, Object... exampleRequests)
Adds the example requests for the method with the specified service type and method name.DocServiceBuilder
exampleRequests(Iterable<?> exampleRequests)
Adds the example requests which are applicable to the method denoted by the specified example requests.DocServiceBuilder
exampleRequests(String serviceName, String methodName, Iterable<?> exampleRequests)
Adds the example requests for the method with the specified service and method name.DocServiceBuilder
exampleRequests(String serviceName, String methodName, Object... exampleRequests)
Adds the example requests for the method with the specified service and method name.DocServiceBuilder
exclude(DocServiceFilter filter)
Adds theDocServiceFilter
that checks whether a method will be excluded while buildingDocService
.DocServiceBuilder
include(DocServiceFilter filter)
Adds theDocServiceFilter
that checks whether a method will be included while buildingDocService
.DocServiceBuilder
injectedScripts(Iterable<String> scripts)
Adds Javascript scripts to inject into the<head />
of the debug page HTML.DocServiceBuilder
injectedScripts(String... scripts)
Adds Javascript scripts to inject into the<head />
of the debug page HTML.DocServiceBuilder
injectedScriptSupplier(BiFunction<ServiceRequestContext,HttpRequest,String> supplier)
Adds a supplier for Javascript scripts to inject into the<head />
of the debug page HTML.
-
Method Details
-
exampleHeaders
Adds the exampleHttpHeaders
which are applicable to any services. -
exampleHeaders
Adds the exampleHttpHeaders
which are applicable to any services. -
exampleHeaders
Adds the exampleHttpHeaders
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 exampleHttpHeaders
for the service with the specified type. This method is a shortcut to:exampleHeaders(serviceType.getName(), exampleHeaders);
-
exampleHeaders
Adds the exampleHttpHeaders
for the service with the specified name. -
exampleHeaders
public DocServiceBuilder exampleHeaders(String serviceName, Iterable<? extends HttpHeaders> exampleHeaders)Adds the exampleHttpHeaders
for the service with the specified name. -
exampleHeaders
public DocServiceBuilder exampleHeaders(Class<?> serviceType, String methodName, HttpHeaders... exampleHeaders)Adds the exampleHttpHeaders
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 exampleHttpHeaders
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 exampleHttpHeaders
for the method with the specified service and method name. -
exampleHeaders
public DocServiceBuilder exampleHeaders(String serviceName, String methodName, Iterable<? extends HttpHeaders> exampleHeaders)Adds the exampleHttpHeaders
for the method with the specified service and method name. -
examplePaths
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
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
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
Adds theDocServiceFilter
that checks whether a method will be included while buildingDocService
. TheDocServiceFilter
will be invoked with the plugin, service and method name. The rule is as follows:- No
include(DocServiceFilter)
andexclude(DocServiceFilter)
is called - include all methods. - Only
exclude(DocServiceFilter)
is called - include all methods except the methods which the exclusion filter returnstrue
. - Only
include(DocServiceFilter)
is called - include the methods which the inclusion filter returnstrue
. include(DocServiceFilter)
andexclude(DocServiceFilter)
is called - include the methods which the inclusion filter returnstrue
and the exclusion filter returnsfalse
.
Note that this can be called multiple times and the
DocServiceFilter
s are composed usingDocServiceFilter.or(DocServiceFilter)
andDocServiceFilter.and(DocServiceFilter)
. - No
-
exclude
Adds theDocServiceFilter
that checks whether a method will be excluded while buildingDocService
. TheDocServiceFilter
will be invoked with the plugin, service and method name. The rule is as follows:- No
include(DocServiceFilter)
andexclude(DocServiceFilter)
is called - include all methods. - Only
exclude(DocServiceFilter)
is called - include all methods except the methods which the exclusion filter returnstrue
. - Only
include(DocServiceFilter)
is called - include the methods which the inclusion filter returnstrue
. include(DocServiceFilter)
andexclude(DocServiceFilter)
is called - include the methods which the inclusion filter returnstrue
and the exclusion filter returnsfalse
.
Note that this can be called multiple times and the
DocServiceFilter
s are composed usingDocServiceFilter.or(DocServiceFilter)
andDocServiceFilter.and(DocServiceFilter)
. - No
-
injectedScripts
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
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 initialDocService
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
Returns a newly-createdDocService
based on the properties of this builder.
-