sideshowcoder / canned

Server to respond with fake API responses, by using a directory of files for finding out what to say!
213 stars 46 forks source link

JSON is not found #99

Closed misantronic closed 8 years ago

misantronic commented 8 years ago

I have the following file-structure:

/api
/api/index.get.html
/api/customer/index.get.json

I start canned via $ canned -p 5000 ./api

localhost:5000/ works. localhost:5000/customer is not working -> request: get /customer/ not found

When I replace /api/customer/index.get.json with /api/customer/index.get.html it works as HTML-file. I also tested all other possibilities from the docs, but I cannot get json-files to work :/

canned: 0.3.8 node: 5.11.0

sideshowcoder commented 8 years ago

Thanks for the report, this seems like a bug which I though would have been covered by the tests but I guessed worngly. If you like to help out identifying the problem it would be great if you could add a test to the /spec/ directory. I will try to figure out what is going on as soon as possible.

CheungJ commented 8 years ago

@misantronic how are you attempting to view localhost:5000/customer? I had an issue where I was seeing a 404 error when trying to access a .json file by opening in the browser, but that doesn't work. After debugging, I realised that accessing the URL via the browser sets the Content-Type as html, therefore canned is trying to retrieve a HTML file.

Is that the case for you?

misantronic commented 8 years ago

Thank you for your replies. I actually just tested canned in the browser. I will try it tomorrow via ajax!

/EDIT: Works fine, thanks a lot!

CheungJ commented 8 years ago

Awesome, glad to hear! The same thing caught me out last week.

sideshowcoder commented 8 years ago

@CheungJ @misantronic anybody mind taking a look if this makes sense to you? https://github.com/sideshowcoder/canned/pull/101