github.com/pavlo67/common@v0.5.3/common/server_http/request.go (about) 1 package server_http 2 3 import ( 4 "net/http" 5 6 "github.com/pavlo67/common/common/auth" 7 ) 8 9 func SetCreds(creds auth.Creds) http.Header { 10 var header http.Header 11 12 if jwt := creds[auth.CredsJWT]; jwt != "" { 13 if header == nil { 14 header = http.Header{} 15 } 16 header.Add("Authorization", jwt) 17 } else if token := creds[auth.CredsToken]; token != "" { 18 if header == nil { 19 header = http.Header{} 20 } 21 header.Add("Authorization", token) 22 } 23 24 return header 25 }