ЛР 3 - БВТ2303 - Голиков - на 5, трек 1 #4

Closed
Maximillan_Mercer wants to merge 36 commits from Maximillan_Mercer/mtusi2026lab3-fork:solution/BVT2303-Golikov into main
2 changed files with 34 additions and 0 deletions
Showing only changes of commit 65ae23f46e - Show all commits
+11
View File
@@ -49,6 +49,17 @@ func (e *AlreadyExistsError) Error() string {
func (e *AlreadyExistsError) Unwrap() error { return ErrAlreadyExists }
func (e *AlreadyExistsError) Code() ErrorCode { return CodeConflict }
type IdempotencyConflictError struct {
Key string
}
func (e *IdempotencyConflictError) Error() string {
return "Idempotency-Key " + e.Key + " уже использован с другим телом запроса"
}
func (e *IdempotencyConflictError) Unwrap() error { return ErrAlreadyExists }
func (e *IdempotencyConflictError) Code() ErrorCode { return CodeConflict }
type ValidationError struct {
Field string
Message string
+23
View File
@@ -0,0 +1,23 @@
package domain
import (
"crypto/sha256"
)
type IdempotencyScope struct {
UserID string
Method string
Path string
Key string
}
type CreateIdempotentResult struct {
Status int
Body []byte
Replayed bool
}
func RequestHash(text string) []byte {
sum := sha256.Sum256([]byte(text))
return sum[:]
}