-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrequests.go
40 lines (33 loc) · 813 Bytes
/
requests.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
package main
import (
"time"
"github.com/fatih/color"
)
const (
// Success is a successful request
Success criticityLevel = iota
// Warning is a successful request but with a bad status
Warning
// Critical is an unsuccessful request
Critical
)
// criticityLevel represents the criticity level of a request
type criticityLevel int
// Colors
var red = color.New(color.FgRed).SprintfFunc()
var green = color.New(color.FgGreen).SprintfFunc()
var yellow = color.New(color.FgYellow).SprintfFunc()
var criticityColor = map[criticityLevel]func(string, ...interface{}) string{
Success: green,
Warning: yellow,
Critical: red,
}
// Request represents a Request interface
type Request interface {
String() string
Error() string
IsError() bool
Status() string
Size() int64
Duration() time.Duration
}