Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identifying the errors #54

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

Identifying the errors #54

wants to merge 29 commits into from

Conversation

tjdharamsi
Copy link
Collaborator

No description provided.

@tjdharamsi
Copy link
Collaborator Author

Hey, I have done sample code for /identity and /message uri.. Is this the way we need to proceed?

public JSONObject toJSON() {
JSONObject jsonobj = new JSONObject();
try {
jsonobj.put("error", "An error occured");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't it explain the error?

Oliver Lee and others added 4 commits July 18, 2014 17:09
Approach to render output in json and html at the same time depending on
the request. For Eg using curl we can get output in json, while normal
browser requests in html.
@tjdharamsi
Copy link
Collaborator Author

Hello all , I wrote this variation which aims to respond on the type of request made ; If used using browser then it will return in html else if using curl on the type of request either json or html it would respond;

But it has no error but on running the server, it just shows the status " Not Found" Restlet Default page;
Could anyone help me figure out what's going wrong?

The changes that i made were going too complicated, Unnecessary classes
have been removed.
@tjdharamsi
Copy link
Collaborator Author

Is there a way to check the type of the response which is expected along with the type of request?

@QuiteStochastic
Copy link
Collaborator

Tejas: for each request, a specific response on expected. what exactly is expected is determined by the API that we wrote. Go check that document, it is king.

@tjdharamsi
Copy link
Collaborator Author

What I meant was for example in class TahrirRestlet in /message we've used if request.getmethod.getName.equals("Get") on the similar lines i was looking for a method similar to this to check for response for what kind of MediaType is expected along with the request. If the response is Html or Json. Presently we set the type of response as part of setEntity(response,Mediatype)

@QuiteStochastic
Copy link
Collaborator

Well according to the API doc, when we receive a GET in /messages, we must return a JSON that looks like this:

{
"messages":[
{
"author_pubkey":"...",
"author_nick":"sanity",
"message_id":124,
"message_hash":"4z...E8",
"content":"hi"
},
{
"author_pubkey":"...",
"author_nick":"some_other_Guy",
"message_id":534,
"message_hash":"dsfgdfsgsdf",
"content":"teeheehe"
}
]
}

So when we set the response, we just set the Mediatype to JSON. I don't see why we shouldn't do this. There's no method to check what the response should be, the requester doesn't give that to us, it just assumes we've read the API doc and have implemented correctly.

@tjdharamsi
Copy link
Collaborator Author

True!!! I was just trying out new stuffs with REST like chrome extension POSTMAN so was trying new thing with it. The above thing was just a example. Whatever we've done till now is exactly as per the API doc written. I was just exploring new things around the REST and Restlet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants