Skip to main content

Crate use_method

Crate use_method 

Source
Expand description

§use-method

Small HTTP method utilities for RustUse.

§Experimental

use-method is experimental while the use-web workspace remains below 0.3.0. Expect small API adjustments during the first release wave.

§Example

use use_method::{is_safe_method, parse_method};

assert!(is_safe_method("GET"));
assert_eq!(parse_method("patch"), Some(use_method::HttpMethod::Patch));

§Scope

  • Lightweight method parsing and normalization.
  • Small helpers for HTTP semantics such as safety and idempotency.
  • Graceful handling for unknown but valid method tokens.

§Non-goals

  • Routing.
  • Middleware.
  • Request execution.
  • Policy engines.

§License

Licensed under either of the following, at your option:

  • Apache License, Version 2.0
  • MIT license

Enums§

HttpMethod
Known HTTP methods plus a variant for valid extension methods.

Functions§

is_idempotent_method
Returns true when the method is defined as idempotent.
is_safe_method
Returns true when the method is defined as safe.
is_standard_method
Returns true when the token is one of the standard request methods.
method_allows_body
Returns true when the method can reasonably carry a body.
method_expects_body
Returns true when the method usually implies a request body.
normalize_method
Normalizes a valid HTTP method token to uppercase.
parse_method
Parses a method token into a standard variant or Other.