github.com/grpc-ecosystem/grpc-gateway/v2@v2.19.1/examples/internal/clients/echo/configuration.go (about) 1 /* 2 * Echo Service 3 * 4 * Echo Service API consists of a single service which returns a message. 5 * 6 * API version: version not set 7 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 */ 9 10 package echo 11 12 import ( 13 "net/http" 14 ) 15 16 // contextKeys are used to identify the type of value in the context. 17 // Since these are string, it is possible to get a short description of the 18 // context key for logging and debugging using key.String(). 19 20 type contextKey string 21 22 func (c contextKey) String() string { 23 return "auth " + string(c) 24 } 25 26 var ( 27 // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. 28 ContextOAuth2 = contextKey("token") 29 30 // ContextBasicAuth takes BasicAuth as authentication for the request. 31 ContextBasicAuth = contextKey("basic") 32 33 // ContextAccessToken takes a string oauth2 access token as authentication for the request. 34 ContextAccessToken = contextKey("accesstoken") 35 36 // ContextAPIKey takes an APIKey as authentication for the request 37 ContextAPIKey = contextKey("apikey") 38 ) 39 40 // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth 41 type BasicAuth struct { 42 UserName string `json:"userName,omitempty"` 43 Password string `json:"password,omitempty"` 44 } 45 46 // APIKey provides API key based authentication to a request passed via context using ContextAPIKey 47 type APIKey struct { 48 Key string 49 Prefix string 50 } 51 52 type Configuration struct { 53 BasePath string `json:"basePath,omitempty"` 54 Host string `json:"host,omitempty"` 55 Scheme string `json:"scheme,omitempty"` 56 DefaultHeader map[string]string `json:"defaultHeader,omitempty"` 57 UserAgent string `json:"userAgent,omitempty"` 58 HTTPClient *http.Client 59 } 60 61 func NewConfiguration() *Configuration { 62 cfg := &Configuration{ 63 BasePath: "https://localhost", 64 DefaultHeader: make(map[string]string), 65 UserAgent: "Swagger-Codegen/1.0.0/go", 66 } 67 return cfg 68 } 69 70 func (c *Configuration) AddDefaultHeader(key string, value string) { 71 c.DefaultHeader[key] = value 72 }