ApiContract

constructor(path: String, httpMethod: HttpMethod = HttpMethod.POST, requestHeaderDecoder: HeaderField<ReqH> = Empty as HeaderField<ReqH>, responseHeaderDecoder: HeaderField<ResH> = Empty as HeaderField<ResH>, pathDecoder: PathField<PathP> = Empty as PathField<PathP>, queryDecoder: QueryField<QueryP> = Empty as QueryField<QueryP>, cookieDecoder: CookieField<CookieP> = Empty as CookieField<CookieP>, requestFormat: BodyFormat<Req>, responseFormat: BodyFormat<Res>, isProtected: Boolean = false)

Parameters

path

The path of the API endpoint. Automatically prefixed with "api/".

httpMethod

The HTTP method to use for the API endpoint. Defaults to HttpMethod.POST.

requestHeaderDecoder

The HeaderField to decode the request headers.

responseHeaderDecoder

The HeaderField to decode the response headers.

pathDecoder

The PathField to decode the path parameters.

queryDecoder

The QueryField to decode the query parameters.

cookieDecoder

The CookieField to decode the request cookies.

requestFormat

The BodyFormat to use for the request body. Defaults to UnitFormat or JsonFormat.

responseFormat

The BodyFormat to use for the response body. Defaults to UnitFormat or JsonFormat.

isProtected

Whether the API endpoint requires authentication. Defaults to false.

Type Parameters

Req

The type of the request body. If the request body is empty, this should be Unit.

Res

The type of the response body. If the response body is empty, this should be Unit.

ReqH

The type of the request headers. Use Empty for no headers.

ResH

The type of the response headers. Use Empty for no headers.

PathP

The type of the path parameters. Use Empty for no path parameters.

QueryP

The type of the query parameters. Use Empty for no query parameters.

CookieP

The type of the request cookies. Use Empty for no cookies.