Crates.io | direct_http |
lib.rs | direct_http |
version | 0.5.5 |
source | src |
created_at | 2023-11-10 21:43:04.786261 |
updated_at | 2023-11-19 04:03:10.037626 |
description | An simple and low-level rust REST API library. |
homepage | |
repository | https://github.com/pedrobartolini/direct_http |
max_upload_size | |
id | 1031476 |
size | 16,444 |
An simple and low-level rust REST API library.
Response
is a struct that represents the HTTP response.
It contains a status enum
that represents the status code, an optional message
of type String
, and optional data
of type Value
.
pub struct Response {
status: Status,
message: Option<String>,
data: Option<Value>,
}
You should always construct the Response using the status you want to return.
Passing an message or data is optional.
let response = Response::status(Status::Ok)
let response = Response::status(Status::Ok).data(ENCODE!(user))
let response = Response::status(Status::Ok).message("Hello world!")
let response = Response::status(Status::Ok).message("Hello world!").data(ENCODE!(user))