grafbase_sdk/types/
hooks.rs1use crate::{types::Headers, wit};
2
3#[non_exhaustive]
5pub struct HttpRequestParts {
6 pub url: String,
8 pub method: http::Method,
10 pub headers: Headers,
12}
13
14impl From<wit::HttpRequestParts> for HttpRequestParts {
15 fn from(parts: wit::HttpRequestParts) -> Self {
16 Self {
17 url: parts.url,
18 method: parts.method.into(),
19 headers: parts.headers.into(),
20 }
21 }
22}
23
24impl From<HttpRequestParts> for wit::HttpRequestParts {
25 fn from(parts: HttpRequestParts) -> Self {
26 Self {
27 url: parts.url,
28 method: parts.method.into(),
29 headers: parts.headers.into(),
30 }
31 }
32}
33
34#[derive(Default)]
36pub struct OnRequestOutput {
37 pub(crate) context: Vec<u8>,
38 pub(crate) contract_key: Option<String>,
39}
40
41impl OnRequestOutput {
42 pub fn new() -> Self {
44 Self::default()
45 }
46
47 pub fn contract_key(mut self, contract_key: impl Into<String>) -> Self {
49 self.contract_key = Some(contract_key.into());
50 self
51 }
52
53 pub fn context(mut self, context: impl Into<Vec<u8>>) -> Self {
56 self.context = context.into();
57 self
58 }
59}