direct_http

Crates.iodirect_http
lib.rsdirect_http
version0.5.5
sourcesrc
created_at2023-11-10 21:43:04.786261
updated_at2023-11-19 04:03:10.037626
descriptionAn simple and low-level rust REST API library.
homepage
repositoryhttps://github.com/pedrobartolini/direct_http
max_upload_size
id1031476
size16,444
Pedro Bartolini (pedrobartolini)

documentation

README

direct_http

An simple and low-level rust REST API library.

Response

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.

response

let response = Response::status(Status::Ok)

response with data

let response = Response::status(Status::Ok).data(ENCODE!(user))

response with message

let response = Response::status(Status::Ok).message("Hello world!")

response with data and message

let response = Response::status(Status::Ok).message("Hello world!").data(ENCODE!(user))

Commit count: 36

cargo fmt