Skip to content

sprint6_v1.0.0#1

Open
St-Ivanov wants to merge 29 commits intomainfrom
first
Open

sprint6_v1.0.0#1
St-Ivanov wants to merge 29 commits intomainfrom
first

Conversation

@St-Ivanov
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

@dirtymew dirtymew 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 internal/handlers/handlers.go Outdated
)

func MainHandler(w http.ResponseWriter, r *http.Request) {
file, err := os.ReadFile("index.html")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

тут можно проще http.ServeFile(w, r, "./index.html")

Comment thread internal/errors/errors.go Outdated
import "errors"

var (
ErrEmptyValue = errors.New("An empty value is received")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ошибки принято с маленькой буквы

Comment thread internal/errors/errors.go Outdated
import "errors"

var (
ErrEmptyValue = errors.New("An empty value is received")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

и кажется это преждевременно

зачем выносить в отдельный пакет то что используется один раз

Comment thread internal/server/server.go Outdated

serv := HttpServer{
Loger: loger, Serv: &http.Server{
Addr: ":8080", Handler: r, ErrorLog: loger, ReadTimeout: time.Duration(5) * time.Second, WriteTimeout: time.Duration(10) * time.Second, IdleTimeout: time.Duration(15) * time.Second,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

лучше построчно перенести - так не читаемая строка получилась

Comment thread internal/service/service.go Outdated

// Проверка строка содержит азбуку морзе.
func isMorseCode(data string) bool {
for _, val := range data {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

есть полезные функции например strings.ContainsFunc

Comment thread internal/handlers/handlers.go Outdated
}
w.Write([]byte(dataParsed + "\n"))
}
w.WriteHeader(http.StatusOK)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

это нужно делать до записи в тело иначе будут сыпаться ошибки и код может клиент не получить

Comment thread internal/handlers/handlers.go Outdated

w.Header().Set("Content-Type", "text/html")

for scanner.Scan() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

тут не нужен сканер - зачем?

читай сразу все боди - не нужно это делать построчно

это ошибка

если первая строка будет состоять из точки? то часть строк будет в морзе часть в тексте это неверная логика

Comment thread internal/handlers/handlers.go Outdated
}

func UploadHandler(w http.ResponseWriter, r *http.Request) {
err := r.ParseMultipartForm(10)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

это зачем? есть понимание что делает ParseMultipartForm и в какой размеренности его параметры?

w.Write(file)
}

func UploadHandler(w http.ResponseWriter, r *http.Request) {
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

@dirtymew dirtymew left a comment

Choose a reason for hiding this comment

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

Степан

все ок - зачет 👍

http.Error(w, "Ошибка при попытке загрузить файл", http.StatusInternalServerError)
return
}
fmt.Fprint(w, dataParsed)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

тут ошибку стоит обработать

}
defer fileNew.Close()

w.Header().Set("Content-Type", "text/html; charset=utf-8")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

хедеры лучше поставить на 52 строке ниже

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