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