ls 5 years ago
parent
commit
ea9c8767ba
2 changed files with 15 additions and 6 deletions
  1. 1 6
      serve.go
  2. 14 0
      utils.go

+ 1 - 6
serve.go

@@ -12,11 +12,6 @@ import (
 	"golang.org/x/net/http2"
 )
 
-const (
-	megaByte = 1 << 20 // 1 mb , 2 mb 1 << 21, 4mb 1 << 22, 8mb 1 << 23
-	gigaByte = 1 << 30
-)
-
 var (
 	readTimeout  = 30 * time.Second
 	writeTimeout = 30 * time.Second
@@ -28,7 +23,7 @@ func newServe(addr string, router http.Handler) *http.Server {
 		Handler:        router,
 		ReadTimeout:    readTimeout,
 		WriteTimeout:   writeTimeout,
-		MaxHeaderBytes: megaByte,
+		MaxHeaderBytes: MB,
 	}
 }
 

+ 14 - 0
utils.go

@@ -5,6 +5,20 @@ import (
 	"encoding/xml"
 )
 
+const (
+	_ = iota
+	// KB  kilo byte
+	KB int = 1 << (10 * iota)
+	// MB mega byte
+	MB
+	// GB giga byte
+	GB
+	// TB tera byte
+	TB
+	// PB peta byte
+	PB
+)
+
 // Map is a shortcut for map[string]interface{}
 type Map map[string]interface{}