Struct direkuta::Direkuta

source ·
pub struct Direkuta { /* private fields */ }
Expand description

The Direkuta web server itself.

Implementations§

Constructs a new Direkuta.

Examples
Direkuta::new();

Set the configuration of the server.

This is an alternative to Direkuta::new() and allows you to set custom paths.

Examples
Direkuta::config(|c| {
    c.template_path("html/templates");
});

Insert a state into server.

Examples
Direkuta::new()
    .state(String::from("Hello World!"));
Panics

Do not use this from anywhere else but the main constructor. Using this from any else will cause a thread panic.

Insert a middleware into server.

Middleware is anything that implements the trait Middle.

Examples
Direkuta::new()
    .middle(Logger::new());
Panics

Do not use this from anywhere else but the main constructor. Using this from any else will cause a thread panic.

Create new router as a closure.

Examples
Direkuta::new()
    .route(|r| {
        // handlers here
    });

Run server as a Hyper server.

Examples
// Not tested due to the fact that its a web server.
Direkuta::new()
    .run("0.0.0.0:3000");
Errors

If any errors come from the server they will be printed to the console.

Trait Implementations§

Returns the “default value” for a type. Read more
The Payload body of the http::Request.
The Payload body of the http::Response.
The error type that can be returned by Services.
The error type that can be returned when creating a new Service.
The resolved Service from new_service().
The future returned from new_service of a Service.
Create a new Service.
The Payload body of the http::Request.
The Payload body of the http::Response.
The error type that can occur within this Service. Read more
The Future returned by this Service.
Calls this Service with a request, returning a Future of the response.
Returns Ready when the service is able to process requests. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The Payload body of the http::Request.
The Payload body of the http::Response.
The error type that can be returned by Services.
The resolved Service from new_service().
The future returned from new_service of a Service.
The error type that can be returned when creating a new Service.
Returns Ready when the constructor is ready to create a new Service. Read more
Create a new Service.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.