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
exampleHttpHeaders(HttpHeaders... exampleHttpHeaders)
Adds the exampleHttpHeaders
which are applicable to any services.DocServiceBuilder
exampleHttpHeaders(Class<?> serviceType, HttpHeaders... exampleHttpHeaders)
Adds the exampleHttpHeaders
for the service with the specified type.DocServiceBuilder
exampleHttpHeaders(Class<?> serviceType, Iterable<? extends HttpHeaders> exampleHttpHeaders)
Adds the exampleHttpHeaders
for the service with the specified type.DocServiceBuilder
exampleHttpHeaders(Class<?> serviceType, String methodName, HttpHeaders... exampleHttpHeaders)
Adds the exampleHttpHeaders
for the method with the specified type and method name.DocServiceBuilder
exampleHttpHeaders(Class<?> serviceType, String methodName, Iterable<? extends HttpHeaders> exampleHttpHeaders)
Adds the exampleHttpHeaders
for the method with the specified type and method name.DocServiceBuilder
exampleHttpHeaders(Iterable<? extends HttpHeaders> exampleHttpHeaders)
Adds the exampleHttpHeaders
which are applicable to any services.DocServiceBuilder
exampleHttpHeaders(String serviceName, HttpHeaders... exampleHttpHeaders)
Adds the exampleHttpHeaders
for the service with the specified name.DocServiceBuilder
exampleHttpHeaders(String serviceName, Iterable<? extends HttpHeaders> exampleHttpHeaders)
Adds the exampleHttpHeaders
for the service with the specified name.DocServiceBuilder
exampleHttpHeaders(String serviceName, String methodName, HttpHeaders... exampleHttpHeaders)
Adds the exampleHttpHeaders
for the method with the specified service and method name.DocServiceBuilder
exampleHttpHeaders(String serviceName, String methodName, Iterable<? extends HttpHeaders> exampleHttpHeaders)
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
exampleRequest(Iterable<?> exampleRequests)
Adds the example requests which are applicable to the method denoted by the specified example requests.DocServiceBuilder
exampleRequest(Object... exampleRequests)
Adds the example requests which are applicable to the method denoted by the specified example requests.DocServiceBuilder
exampleRequestForMethod(Class<?> serviceType, String methodName, Iterable<?> exampleRequests)
Adds the example requests for the method with the specified service type and method name.DocServiceBuilder
exampleRequestForMethod(Class<?> serviceType, String methodName, Object... exampleRequests)
Adds the example requests for the method with the specified service type and method name.DocServiceBuilder
exampleRequestForMethod(String serviceName, String methodName, Iterable<?> exampleRequests)
Adds the example requests for the method with the specified service and method name.DocServiceBuilder
exampleRequestForMethod(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
injectedScript(Iterable<String> scripts)
Adds Javascript scripts to inject into the<head />
of the debug page HTML.DocServiceBuilder
injectedScript(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
-
exampleHttpHeaders
Adds the exampleHttpHeaders
which are applicable to any services. -
exampleHttpHeaders
Adds the exampleHttpHeaders
which are applicable to any services. -
exampleHttpHeaders
public DocServiceBuilder exampleHttpHeaders(Class<?> serviceType, HttpHeaders... exampleHttpHeaders)Adds the exampleHttpHeaders
for the service with the specified type. This method is a shortcut to:exampleHttpHeaders(serviceType.getName(), exampleHttpHeaders);
-
exampleHttpHeaders
public DocServiceBuilder exampleHttpHeaders(Class<?> serviceType, Iterable<? extends HttpHeaders> exampleHttpHeaders)Adds the exampleHttpHeaders
for the service with the specified type. This method is a shortcut to:exampleHttpHeaders(serviceType.getName(), exampleHttpHeaders);
-
exampleHttpHeaders
Adds the exampleHttpHeaders
for the service with the specified name. -
exampleHttpHeaders
public DocServiceBuilder exampleHttpHeaders(String serviceName, Iterable<? extends HttpHeaders> exampleHttpHeaders)Adds the exampleHttpHeaders
for the service with the specified name. -
exampleHttpHeaders
public DocServiceBuilder exampleHttpHeaders(Class<?> serviceType, String methodName, HttpHeaders... exampleHttpHeaders)Adds the exampleHttpHeaders
for the method with the specified type and method name. This method is a shortcut to:exampleHttpHeaders(serviceType.getName(), methodName, exampleHttpHeaders);
-
exampleHttpHeaders
public DocServiceBuilder exampleHttpHeaders(Class<?> serviceType, String methodName, Iterable<? extends HttpHeaders> exampleHttpHeaders)Adds the exampleHttpHeaders
for the method with the specified type and method name. This method is a shortcut to:exampleHttpHeaders(serviceType.getName(), methodName, exampleHttpHeaders);
-
exampleHttpHeaders
public DocServiceBuilder exampleHttpHeaders(String serviceName, String methodName, HttpHeaders... exampleHttpHeaders)Adds the exampleHttpHeaders
for the method with the specified service and method name. -
exampleHttpHeaders
public DocServiceBuilder exampleHttpHeaders(String serviceName, String methodName, Iterable<? extends HttpHeaders> exampleHttpHeaders)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. -
exampleRequestForMethod
public DocServiceBuilder exampleRequestForMethod(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:exampleRequest(serviceType.getName(), exampleRequests);
-
exampleRequestForMethod
public DocServiceBuilder exampleRequestForMethod(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:exampleRequest(serviceType.getName(), exampleRequests);
-
exampleRequestForMethod
public DocServiceBuilder exampleRequestForMethod(String serviceName, String methodName, Object... exampleRequests)Adds the example requests for the method with the specified service and method name. -
exampleRequestForMethod
public DocServiceBuilder exampleRequestForMethod(String serviceName, String methodName, Iterable<?> exampleRequests)Adds the example requests for the method with the specified service and method name. -
exampleRequest
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
-
exampleRequest
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
-
injectedScript
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' }); });
-
injectedScript
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.
-