github.com/pzeinlinger/servefiles@v3.1.0+incompatible/util.go (about) 1 package servefiles 2 3 import "strings" 4 5 type commaSeparatedList string 6 7 func (list commaSeparatedList) Contains(want string) bool { 8 accepted := strings.Split(string(list), ",") 9 for _, encoding := range accepted { 10 if strings.TrimSpace(encoding) == want { 11 return true 12 } 13 } 14 return false 15 } 16 17 //------------------------------------------------------------------------------------------------- 18 19 type code int 20 21 const ( 22 Directory code = 0 23 Continue code = 100 24 //OK code = 200 25 //NotModified code = 304 26 Forbidden code = 403 27 NotFound code = 404 28 ServiceUnavailable code = 503 29 ) 30 31 func (code code) String() string { 32 switch code { 33 case Continue: 34 return "100 Continue" 35 //case OK: 36 // return "200 OK" 37 //case NotModified: 38 // return "304 Not modified" 39 case Forbidden: 40 return "403 Forbidden" 41 case NotFound: 42 return "404 Not found" 43 case ServiceUnavailable: 44 return "503 Service unavailable" 45 } 46 panic(code) 47 }