pub struct Endpoint { /* private fields */ }Expand description
A REST endpoint, spelled the way GitHub’s own documentation spells one.
GET /repos/{owner}/{repo}/labels: a method and a path template whose segments are
literals or {placeholder}s, never the URL a run built from it. That is what makes two
runs’ reports compare line for line, and it is why this is a type with one constructor
rather than a string a caller fills in — a record holding
https://api.github.com/repos/octo-org/board/labels?per_page=100 would put a board’s
name, and whatever else a query string carried, into a report that promises to carry
neither.
What it rules on, and what it cannot. Endpoint::parse refuses a host, a query
string, a fragment, whitespace, a byte outside the small set a path template is spelled
from, and anything long — every way an addressed URL differs in shape from a template.
It cannot tell a template’s literal segment from a filled-in one, because
/repos/octo-org/board/labels is spelled exactly like a template of literals; keeping
the placeholders unfilled is the caller’s, and the reason Request::rest’s own
documentation says to pass the template.
Implementations§
Source§impl Endpoint
impl Endpoint
Sourcepub fn parse(method: Method, path: &str) -> Option<Self>
pub fn parse(method: Method, path: &str) -> Option<Self>
The endpoint path spells under method, or None when path is not spelled like
a path template at all.
Refusing it here is refusing it where it is written, which is the same answer
Method::parse gives a method HTTP has no verb for: a caller learns at the call
site rather than finding a URL in a report that was supposed to hold none.