← Back

Module http

enum Method

Source: http.joule:13

fn as_str(&self) -> &str

Source: http.joule:26

fn from_str(s: &str) -> Option<Self>

Source: http.joule:40

struct StatusCode(pub u16);

Source: http.joule:58

const CONTINUE: StatusCode

Source: http.joule:62

const SWITCHING_PROTOCOLS: StatusCode

Source: http.joule:63

const OK: StatusCode

Source: http.joule:66

const CREATED: StatusCode

Source: http.joule:67

const ACCEPTED: StatusCode

Source: http.joule:68

const NO_CONTENT: StatusCode

Source: http.joule:69

const MOVED_PERMANENTLY: StatusCode

Source: http.joule:72

const FOUND: StatusCode

Source: http.joule:73

const NOT_MODIFIED: StatusCode

Source: http.joule:74

const TEMPORARY_REDIRECT: StatusCode

Source: http.joule:75

const PERMANENT_REDIRECT: StatusCode

Source: http.joule:76

const BAD_REQUEST: StatusCode

Source: http.joule:79

const UNAUTHORIZED: StatusCode

Source: http.joule:80

const FORBIDDEN: StatusCode

Source: http.joule:81

const NOT_FOUND: StatusCode

Source: http.joule:82

const METHOD_NOT_ALLOWED: StatusCode

Source: http.joule:83

const CONFLICT: StatusCode

Source: http.joule:84

const GONE: StatusCode

Source: http.joule:85

const TOO_MANY_REQUESTS: StatusCode

Source: http.joule:86

const INTERNAL_SERVER_ERROR: StatusCode

Source: http.joule:89

const NOT_IMPLEMENTED: StatusCode

Source: http.joule:90

const BAD_GATEWAY: StatusCode

Source: http.joule:91

const SERVICE_UNAVAILABLE: StatusCode

Source: http.joule:92

const GATEWAY_TIMEOUT: StatusCode

Source: http.joule:93

fn is_success(&self) -> bool

Source: http.joule:95

fn is_redirect(&self) -> bool

Source: http.joule:99

fn is_client_error(&self) -> bool

Source: http.joule:103

fn is_server_error(&self) -> bool

Source: http.joule:107

fn reason_phrase(&self) -> &str

Source: http.joule:111

struct Headers

Source: http.joule:136

fn new() -> Self

Source: http.joule:141

fn set(&mut self, name: &str, value: &str)

Set a header (replaces existing)

Source: http.joule:148

fn add(&mut self, name: &str, value: &str)

Add a header value (appends to existing)

Source: http.joule:154

fn get(&self, name: &str) -> Option<&str>

Get first header value

Source: http.joule:163

fn get_all(&self, name: &str) -> Option<&Vec<String>>

Get all values for a header

Source: http.joule:171

fn contains(&self, name: &str) -> bool

Check if header exists

Source: http.joule:176

fn remove(&mut self, name: &str) -> Option<Vec<String>>

Remove a header

Source: http.joule:181

fn iter(&self) -> impl Iterator<Item = (&String, &Vec<String>)>

Iterate over headers

Source: http.joule:186

fn content_length(&self) -> Option<usize>

Get content-length if present

Source: http.joule:191

fn content_type(&self) -> Option<&str>

Get content-type if present

Source: http.joule:197

struct Request

HTTP request

Source: http.joule:203

fn get(uri: &str) -> Self

Create new GET request

Source: http.joule:213

fn post(uri: &str) -> Self

Create new POST request

Source: http.joule:224

fn new(method: Method, uri: &str) -> Self

Create new request with method

Source: http.joule:235

fn header(mut self, name: &str, value: &str) -> Self

Set header

Source: http.joule:246

fn body(mut self, body: Vec<u8>) -> Self

Set body

Source: http.joule:252

fn json<T: serde::Serialize>(mut self, value: &T) -> Result<Self, HttpError>

Set JSON body

Source: http.joule:258

fn form(mut self, data: &[(String, String)]) -> Self

Set form body

Source: http.joule:266

fn to_bytes(&self) -> Vec<u8>

Serialize to bytes

Source: http.joule:279

fn parse<R: Read>(reader: &mut R) -> Result<Self, HttpError>

Parse from stream

Source: http.joule:314

struct Response

HTTP response

Source: http.joule:364

fn new(status: StatusCode) -> Self

Create new response

Source: http.joule:373

fn ok() -> Self

Create OK response

Source: http.joule:383

fn not_found() -> Self

Create not found response

Source: http.joule:388

fn header(mut self, name: &str, value: &str) -> Self

Set header

Source: http.joule:393

fn body(mut self, body: Vec<u8>) -> Self

Set body

Source: http.joule:399

fn text(mut self, text: &str) -> Self

Set text body

Source: http.joule:405

fn html(mut self, html: &str) -> Self

Set HTML body

Source: http.joule:412

fn json<T: serde::Serialize>(mut self, value: &T) -> Result<Self, HttpError>

Set JSON body

Source: http.joule:419

fn json_body<T: serde::de::DeserializeOwned>(&self) -> Result<T, HttpError>

Parse response body as JSON

Source: http.joule:427

fn text_body(&self) -> Result<String, HttpError>

Get body as string

Source: http.joule:432

fn to_bytes(&self) -> Vec<u8>

Serialize to bytes

Source: http.joule:438

fn parse<R: Read>(reader: &mut R) -> Result<Self, HttpError>

Parse from stream

Source: http.joule:473

struct ClientConfig

HTTP client configuration

Source: http.joule:528

fn default() -> Self

Source: http.joule:537

struct HttpClient

HTTP client

Source: http.joule:549

fn new() -> Self

Create new client

Source: http.joule:555

fn with_config(config: ClientConfig) -> Self

Create with config

Source: http.joule:562

fn send(&self, mut request: Request) -> Result<Response, HttpError>

Source: http.joule:568

fn follow_redirect(&self, location: &str, count: u32) -> Result<Response, HttpError>

Source: http.joule:606

fn get(&self, url: &str) -> Result<Response, HttpError>

Source: http.joule:617

fn post(&self, url: &str, body: Vec<u8>) -> Result<Response, HttpError>

Source: http.joule:623

fn post_json<T: serde::Serialize>(&self, url: &str, value: &T) -> Result<Response, HttpError>

Source: http.joule:629

fn put(&self, url: &str, body: Vec<u8>) -> Result<Response, HttpError>

Source: http.joule:635

fn delete(&self, url: &str) -> Result<Response, HttpError>

Source: http.joule:641

trait Handler: Send + Sync

HTTP server handler trait

Source: http.joule:651

fn handle(&self, request: Request) -> Response;

Source: http.joule:652

struct HttpServer

HTTP server

Source: http.joule:656

fn new<H: Handler + 'static>(addr: &str, handler: H) -> Result<Self, HttpError>

Source: http.joule:664

fn run(&self) -> Result<(), HttpError>

Source: http.joule:674

fn run_threaded(&self, num_threads: usize) -> Result<(), HttpError>

Source: http.joule:689

fn handle_connection(&self, mut stream: TcpStream) -> Result<(), HttpError>

Source: http.joule:714

fn local_addr(&self) -> &SocketAddr

Get local address

Source: http.joule:722

struct FnHandler

Simple function-based handler

Source: http.joule:728

fn handle(&self, request: Request) -> Response

Source: http.joule:734

struct Router

Router for path-based routing

Source: http.joule:740

fn new() -> Self

Source: http.joule:745

fn get<F>(mut self, path: &str, handler: F) -> Self

Source: http.joule:749

fn post<F>(mut self, path: &str, handler: F) -> Self

Source: http.joule:757

fn put<F>(mut self, path: &str, handler: F) -> Self

Source: http.joule:765

fn delete<F>(mut self, path: &str, handler: F) -> Self

Source: http.joule:773

fn handle(&self, request: Request) -> Response

Source: http.joule:783

struct Url

Source: http.joule:800

fn parse(url: &str) -> Result<Self, HttpError>

Source: http.joule:809

enum HttpError

Source: http.joule:843

fn from(e: std::io::Error) -> Self

Source: http.joule:855

fn from(e: TcpError) -> Self

Source: http.joule:861

fn from(e: serde_json::Error) -> Self

Source: http.joule:867

fn read_line<R: Read>(reader: &mut R, buf: &mut String) -> Result<(), HttpError>

Source: http.joule:876

fn read_chunked_body<R: Read>(reader: &mut R) -> Result<Vec<u8>, HttpError>

Source: http.joule:891

fn url_encode(s: &str) -> String

Source: http.joule:919

fn path_matches(pattern: &str, path: &str) -> bool

Source: http.joule:936