wit_ai/api/endpoints/
mod.rs1use hyper::{body::Bytes, Method};
2
3use super::Error;
4
5pub mod message;
6
7#[derive(Debug, Clone)]
8pub enum Endpoint {
9 Message(String),
10}
11
12pub trait ParseBody<T> {
13 fn parse_body(&self, body: Bytes) -> Result<T, Error>;
14}
15
16impl ParseBody<String> for Endpoint {
17 fn parse_body(&self, body: hyper::body::Bytes) -> Result<String, Error> {
18 Ok(format!("{:?}", body))
19 }
20}
21
22impl Endpoint {
23 pub fn body(&self) -> hyper::Body {
24 match self {
25 _ => hyper::Body::empty(),
26 }
27 }
28
29 pub fn method(&self) -> Method {
30 match self {
31 _ => Method::GET,
32 }
33 }
34
35 pub fn path(&self) -> String {
36 match self {
37 Endpoint::Message(_) => message::path(self),
38 }
39 }
40
41 pub fn params(&self) -> Vec<(String, String)> {
42 match self {
43 Endpoint::Message(_) => message::params(self),
44 }
45 }
46}