public class Api<T extends ComponentsProvider>
A model describing an API; it contains the routes to the API endpoints and the code executed when the API receives requests.
| Modifier and Type | Class and Description |
|---|---|
static class |
Api.Companion |
| Modifier and Type | Field and Description |
|---|---|
static Api.Companion |
Companion |
| Constructor and Description |
|---|
Api(java.util.List<? extends ws.osiris.core.Route<T>> routes,
java.util.List<ws.osiris.core.Filter> filters,
kotlin.reflect.KClass<? super T> componentsClass,
boolean staticFiles,
java.util.Set<java.lang.String> binaryMimeTypes)
A model describing an API; it contains the routes to the API endpoints and the code executed
when the API receives requests.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.List<ws.osiris.core.Route> |
component1()
The routes defined by the API.
|
java.util.List<ws.osiris.core.Filter> |
component2()
Filters applied to requests before they are passed to a handler.
|
kotlin.reflect.KClass<? super T> |
component3()
The type of the object available to the code in the API definition that handles the HTTP requests.
|
boolean |
component4()
True if this API serves static files.
|
java.util.Set<java.lang.String> |
component5()
The MIME types that are treated by API Gateway as binary;
|
Api<T> |
copy(java.util.List<? extends ws.osiris.core.Route<T>> routes,
java.util.List<ws.osiris.core.Filter> filters,
kotlin.reflect.KClass<? super T> componentsClass,
boolean staticFiles,
java.util.Set<java.lang.String> binaryMimeTypes)
A model describing an API; it contains the routes to the API endpoints and the code executed
when the API receives requests.
|
boolean |
equals(java.lang.Object p) |
java.util.Set<java.lang.String> |
getBinaryMimeTypes()
The MIME types that are treated by API Gateway as binary;
|
kotlin.reflect.KClass<? super T> |
getComponentsClass()
The type of the object available to the code in the API definition that handles the HTTP requests.
|
java.util.List<ws.osiris.core.Filter> |
getFilters()
Filters applied to requests before they are passed to a handler.
|
java.util.List<ws.osiris.core.Route> |
getRoutes()
The routes defined by the API.
|
boolean |
getStaticFiles()
True if this API serves static files.
|
int |
hashCode() |
java.lang.String |
toString() |
public static Api.Companion Companion
public Api(@NotNull
java.util.List<? extends ws.osiris.core.Route<T>> routes,
@NotNull
java.util.List<ws.osiris.core.Filter> filters,
@NotNull
kotlin.reflect.KClass<? super T> componentsClass,
boolean staticFiles,
@NotNull
java.util.Set<java.lang.String> binaryMimeTypes)
A model describing an API; it contains the routes to the API endpoints and the code executed when the API receives requests.
routes - The routes defined by the API.
Each route consists of:
An HTTP method
A path
The code that is executed when a request is received for the endpoint
The authorisation required to invoke the endpoint.
filters - Filters applied to requests before they are passed to a handler.componentsClass - The type of the object available to the code in the API definition that handles the HTTP requests.
The code in the API definition runs with the components provider class as the implicit receiver and can directly access its properties and methods.
For example, if a data store is needed to handle a request, it would be provided by
the ComponentsProvider implementation:
class Components(val dataStore: DataStore) : ComponentsProvider
...
get("/orders/{orderId}") { req ->
val orderId = req.pathParams["orderId"]
dataStore.loadOrderDetails(orderId)
}staticFiles - True if this API serves static files.binaryMimeTypes - The MIME types that are treated by API Gateway as binary; these are encoded in the JSON using Base64.@NotNull public java.util.List<ws.osiris.core.Route> getRoutes()
The routes defined by the API.
Each route consists of:
An HTTP method
A path
The code that is executed when a request is received for the endpoint
The authorisation required to invoke the endpoint.
@NotNull public java.util.List<ws.osiris.core.Filter> getFilters()
Filters applied to requests before they are passed to a handler.
@NotNull public kotlin.reflect.KClass<? super T> getComponentsClass()
The type of the object available to the code in the API definition that handles the HTTP requests.
The code in the API definition runs with the components provider class as the implicit receiver and can directly access its properties and methods.
For example, if a data store is needed to handle a request, it would be provided by
the ComponentsProvider implementation:
class Components(val dataStore: DataStore) : ComponentsProvider
...
get("/orders/{orderId}") { req ->
val orderId = req.pathParams["orderId"]
dataStore.loadOrderDetails(orderId)
}public boolean getStaticFiles()
True if this API serves static files.
@NotNull public java.util.Set<java.lang.String> getBinaryMimeTypes()
The MIME types that are treated by API Gateway as binary;
these are encoded in the JSON using Base64.
@NotNull public java.util.List<ws.osiris.core.Route> component1()
The routes defined by the API.
Each route consists of:
An HTTP method
A path
The code that is executed when a request is received for the endpoint
The authorisation required to invoke the endpoint.
@NotNull public java.util.List<ws.osiris.core.Filter> component2()
Filters applied to requests before they are passed to a handler.
@NotNull public kotlin.reflect.KClass<? super T> component3()
The type of the object available to the code in the API definition that handles the HTTP requests.
The code in the API definition runs with the components provider class as the implicit receiver and can directly access its properties and methods.
For example, if a data store is needed to handle a request, it would be provided by
the ComponentsProvider implementation:
class Components(val dataStore: DataStore) : ComponentsProvider
...
get("/orders/{orderId}") { req ->
val orderId = req.pathParams["orderId"]
dataStore.loadOrderDetails(orderId)
}public boolean component4()
True if this API serves static files.
@NotNull public java.util.Set<java.lang.String> component5()
The MIME types that are treated by API Gateway as binary;
these are encoded in the JSON using Base64.
@NotNull public Api<T> copy(@NotNull java.util.List<? extends ws.osiris.core.Route<T>> routes, @NotNull java.util.List<ws.osiris.core.Filter> filters, @NotNull kotlin.reflect.KClass<? super T> componentsClass, boolean staticFiles, @NotNull java.util.Set<java.lang.String> binaryMimeTypes)
A model describing an API; it contains the routes to the API endpoints and the code executed when the API receives requests.
@NotNull public java.lang.String toString()
public int hashCode()
public boolean equals(@Nullable
java.lang.Object p)