-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathutil.go
45 lines (35 loc) · 844 Bytes
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package main
import (
"fmt"
"net/http"
)
type ErrorType int
const (
ClientInvalidRequest ErrorType = iota
)
func (t ErrorType) String() string {
switch t {
case ClientInvalidRequest:
return "Client.InvalidRequest"
}
return fmt.Sprintf("Cannot stringify standalone.ErrorType.%d", int(t))
}
type ResponseWriterProxy struct {
Body []byte
StatusCode int
}
func (w *ResponseWriterProxy) Header() http.Header {
return http.Header{}
}
func (w *ResponseWriterProxy) Write(b []byte) (int, error) {
w.Body = b
return 0, nil
}
func (w *ResponseWriterProxy) WriteHeader(statusCode int) {
w.StatusCode = statusCode
}
func (w *ResponseWriterProxy) IsError() bool {
return w.StatusCode != 0 && w.StatusCode/100 != 2
}