Fix /api/read and /api/subscribe, re-add debug output

This commit is contained in:
Lucien Greathouse
2019-02-22 15:56:24 -08:00
parent c9a663ed39
commit 4f31c9e72f
2 changed files with 6 additions and 3 deletions

View File

@@ -10,8 +10,8 @@ use std::{
use futures::{future, Future};
use hyper::{
service::Service,
StatusCode,
header,
StatusCode,
Method,
Body,
Request,
@@ -153,7 +153,7 @@ impl ApiService {
/// Retrieve any messages past the given cursor index, and if
/// there weren't any, subscribe to receive any new messages.
fn handle_api_subscribe(&self, request: Request<Body>) -> Response<Body> {
let argument = &request.uri().path()["/api/subscribe".len()..];
let argument = &request.uri().path()["/api/subscribe/".len()..];
let cursor: u32 = match argument.parse() {
Ok(v) => v,
Err(err) => {
@@ -206,7 +206,7 @@ impl ApiService {
}
fn handle_api_read(&self, request: Request<Body>) -> Response<Body> {
let argument = &request.uri().path()["/api/subscribe".len()..];
let argument = &request.uri().path()["/api/read/".len()..];
let requested_ids: Option<Vec<RbxId>> = argument
.split(',')
.map(RbxId::parse_str)

View File

@@ -5,6 +5,7 @@ mod interface;
use std::sync::Arc;
use log::trace;
use futures::{
future::{self, FutureResult},
Future,
@@ -38,6 +39,8 @@ impl Service for RootService {
type Future = Box<dyn Future<Item = Response<Self::ReqBody>, Error = Self::Error> + Send>;
fn call(&mut self, request: Request<Self::ReqBody>) -> Self::Future {
trace!("{} {}", request.method(), request.uri().path());
if request.uri().path().starts_with("/api") {
self.api.call(request)
} else {