Skip to main content

resolve_http_verb

Function resolve_http_verb 

Source
pub fn resolve_http_verb(method: &str, path_has_params: bool) -> String
Expand description

Map an HTTP method to its semantic verb.

GET is contextual: collection routes (no path params) map to "list", single-resource routes (with path params) map to "get". All other methods have a static mapping. Unknown methods fall through to the lowercase form of the input.

§Arguments

  • method - HTTP method string (case-insensitive).
  • path_has_params - True if the corresponding route has path parameters.

§Examples

use apcore_toolkit::http_verb_map::resolve_http_verb;

assert_eq!(resolve_http_verb("POST", false), "create");
assert_eq!(resolve_http_verb("GET", false), "list");
assert_eq!(resolve_http_verb("GET", true), "get");