Skip to content

Sprint 9 solution http api#5

Open
LevshaKS wants to merge 5 commits into
mainfrom
sprint_9-solution-http-api
Open

Sprint 9 solution http api#5
LevshaKS wants to merge 5 commits into
mainfrom
sprint_9-solution-http-api

Conversation

@LevshaKS
Copy link
Copy Markdown
Owner

ТЗ 9

Copy link
Copy Markdown

@avfyodorov avfyodorov left a comment

Choose a reason for hiding this comment

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

Добрый день, Константин!

Хорошая работа, от меня всего пара уточнений.

Просьба обратить дополнительное внимание на возвращаемые коды ошибок:
400 BAD_REQUEST - Ошибка в самом запросе, не удаётся его правильно разобрать.
404 NOT FOUND - это правильный запрос, просто нет данных
405 METHOD_NOT_ALLOWED - Пришло что-то непонятное, с этим мы не работаем

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405

Comment thread src/http/HttpTaskServer.java Outdated
httpServer.createContext("/prioritized", new PrioritizedHandler(manager));
}

public static Gson getGson() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно было бы вынести создание Gson в класс BaseHttpHandler, чтобы был доступ прямо в наследниках.

Comment thread src/http/handler/EpicTaskHandler.java Outdated
System.out.println("возвращаем епик " + idPath);
} else {
sendNotFound(httpExchange);
System.out.println("нет такого действия");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Если пришло непонятно что, то возвращать нужно

405 METHOD_NOT_ALLOWED

Почему возвращается статус 405 METHOD_NOT_ALLOWED можно посмотреть тут: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405

Comment thread src/http/handler/EpicTaskHandler.java Outdated
}
}
default:
sendNotFound(httpExchange);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Если пришло непонятно что, то возвращать нужно либо
400 BAD_REQUEST
либо
405 METHOD_NOT_ALLOWED

Comment thread src/http/handler/HistoryHandler.java Outdated
@Override
public void handle(HttpExchange httpExchange) throws IOException {
final String path = httpExchange.getRequestURI().getPath();
System.out.println(path);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Отладочную печать всё-таки лучше удалять после окончания разработки.
На усмотрение.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

какие то убрал, какие то сократил. С ними пока что удобнее ориентироваться в коде

Copy link
Copy Markdown

@avfyodorov avfyodorov left a comment

Choose a reason for hiding this comment

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

Добрый вечер, Константин!

Отметил момент, который можно было бы поправить, но, думаю, что Вы справитесь и вне ревью. 🙂
Работа принята.

Comment thread src/http/handler/EpicTaskHandler.java Outdated
public class EpicTaskHandler extends BaseHttpHandler implements HttpHandler {

private final TaskManager manager;
private final Gson gson;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Переменную также можно было бы перенести в базовый класс, один раз создать и использовать.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Добрый день. Исправил

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.

2 participants