-
Notifications
You must be signed in to change notification settings - Fork 0
Sprint 9 solution http api #4
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
base: main
Are you sure you want to change the base?
Conversation
src/Managers.java
Outdated
| public static TaskManager getDefault() { | ||
| return new FileBackedTaskManager(); | ||
| /* FileBackedTaskManager manager = | ||
| FileBackedTaskManager.loadFromFile(new File (".\\data\\tasks.csv")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лишний код лучше убирать
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Выполнено.
src/BaseHttpHandler.java
Outdated
| public class BaseHttpHandler { | ||
| protected static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; | ||
|
|
||
| public void sendText(HttpExchange h, String text, int retCode) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Классы, которые реализуют интерфейс AutoCloseable можно обрабатывать с помощью try with resources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавил обработку исключений.
src/BaseHttpHandler.java
Outdated
| public class BaseHttpHandler { | ||
| protected static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; | ||
|
|
||
| public void sendText(HttpExchange h, String text, int retCode) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Более оптимальным вариантом обработки исключений является использование блоков try catch, так как это позволяет сделать более гибкую обработку ошибок(например добавить логи) и избавляет от необходимости пробрасывать исключения по цепочке
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавил try catch в обработчики http запросов.
src/BaseHttpHandler.java
Outdated
| * | ||
| * @return - объект конвертера gson | ||
| */ | ||
| public Gson getGson() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gson лучше сделать статическим, это избавит от необходимости каждый раз создавать новый объект
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Выполнено.
| import java.time.LocalDateTime; | ||
| import java.util.Optional; | ||
|
|
||
| public class BaseHttpHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Было бы хорошо структурировать проект, например все классы связанные с обработкой http вынести в отдельную папку
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Распределил все классы по пакетам.
No description provided.