/// Produces the correct response for the given request.
Produces the correct response for the given request.
Produces the correct response for the given request .
fn from_request(
        sock: TcpStream,
        origins: OriginsHistory,
        req: &httparse::Request
    ) -> Self {
        if req.method != Some("GET") {
            return Self::method_not_allowed(sock)
        }
        if let Some(path) = req.path {
            match path {
                "/csv" => {
                    VrpResponse::response(sock, origins, OutputFormat::Csv)
                }
                "/json" => {
                    VrpResponse::response(sock, origins, OutputFormat::Json)
                }
                "/metrics" => {
                    Self::metrics(sock, origins)
                }
                "/openbgpd" => {
                    VrpResponse::response(
                        sock, origins, OutputFormat::Openbgpd
                    )
                }
                "/rpsl" => {
                    VrpResponse::response(
                        sock, origins, OutputFormat::Rpsl
                    )
                }
                "/status" => Self::text(sock, "fine"),
                "/version" => Self::text(sock, crate_version!()),
                _ => Self::not_found(sock),
            }
        }
        else {
            Self::not_found(sock)
        }
    }
fn from_request ( sock : TcpStream , origins : OriginsHistory , req : & httparse :: Request ) -> Self { if req . method != Some ( " " ) { return Self :: method_not_allowed ( sock ) } if let Some ( path ) = req . path { match path { " " => { VrpResponse :: response ( sock , origins , OutputFormat :: Csv ) } " " => { VrpResponse :: response ( sock , origins , OutputFormat :: Json ) } " " => { Self :: metrics ( sock , origins ) } " " => { VrpResponse :: response ( sock , origins , OutputFormat :: Openbgpd ) } " " => { VrpResponse :: response ( sock , origins , OutputFormat :: Rpsl ) } " " => Self :: text ( sock , " " ) , " " => Self :: text ( sock , crate_version ! ( ) ) , _ => Self :: not_found ( sock ) , } } else { Self :: not_found ( sock ) } }
Produces the correct response for the given request.
Produces the correct response for the given request .
sock
TcpStream
origins
OriginsHistory
req
&httparse::Request