Class RestDefinition

Assembly: redb.Route.Http.dll

REST DSL (Apache Camel rest() parity) on top of the HTTP consumer and the shared Kestrel host:
every verb becomes an ordinary route From("http://host:port/base/path?methods=GET&inOut=true"),
so path templates, method dispatch (405), CORS, TLS and everything else stay where they already are.
The DSL adds the declarative layer: path parameters as header.id, query as header.query.page,
Consumes / Produces with 415 on mismatch, JSON binding to CLR types, and an OpenAPI 3.0
document generated from the declarations.

this.Rest("/api/orders", o => o.Port = 8080)
.Get("/{id}").To("direct:get-order")
.Post().Consumes("application/json").Type<Order>().To("direct:create-order")
.Put("/{id}/status").To("direct:set-status")
.Delete("/{id}").To("direct:cancel-order");

public sealed class RestDefinition

Inheritance

Object→RestDefinition

Properties

BasePath

Common path prefix of the verbs (/api/orders).

public string BasePath { get; }

OpenApiPath

Path the OpenAPI document is served at ( or {basePath}/openapi.json).

public string OpenApiPath { get; }

Options

Settings of this declaration.

public RestOptions Options { get; }

Verbs

Verbs declared so far (completed with To / Route).

public IReadOnlyList<RestVerbDefinition> Verbs { get; }

Methods

Delete(string)

Declares a DELETE operation.

public RestVerbDefinition Delete(string path = "")

Get(string)

Declares a GET operation.

public RestVerbDefinition Get(string path = "")

Head(string)

Declares a HEAD operation.

public RestVerbDefinition Head(string path = "")

Patch(string)

Declares a PATCH operation.

public RestVerbDefinition Patch(string path = "")

Post(string)

Declares a POST operation.

public RestVerbDefinition Post(string path = "")

Put(string)

Declares a PUT operation.

public RestVerbDefinition Put(string path = "")