forked from mtusi2026/mtusi2026lab2
chore: port lab 1 solution
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"mtusi2026-messenger/internal/dto"
|
||||
)
|
||||
|
||||
func WriteError(
|
||||
w http.ResponseWriter,
|
||||
status int,
|
||||
code dto.ErrorCode,
|
||||
message string,
|
||||
requestID string,
|
||||
) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(status)
|
||||
|
||||
_ = json.NewEncoder(w).Encode(dto.ErrorResponse{
|
||||
Error: dto.Error{
|
||||
Code: code,
|
||||
Message: message,
|
||||
RequestID: requestID,
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user