| 
									
										
										
										
											2018-08-07 11:56:55 +02:00
										 |  |  | package sctx | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-15 17:41:52 +02:00
										 |  |  | import "context" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 11:56:55 +02:00
										 |  |  | type ContextKey int | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const ( | 
					
						
							|  |  |  | 	HTTPRequestIDKey ContextKey = iota | 
					
						
							| 
									
										
										
										
											2018-08-15 17:41:52 +02:00
										 |  |  | 	requestHostKey | 
					
						
							| 
									
										
										
										
											2018-08-07 11:56:55 +02:00
										 |  |  | ) | 
					
						
							| 
									
										
										
										
											2018-08-15 17:41:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | func SetHost(ctx context.Context, domain string) context.Context { | 
					
						
							|  |  |  | 	return context.WithValue(ctx, requestHostKey, domain) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func GetHost(ctx context.Context) string { | 
					
						
							|  |  |  | 	v, ok := ctx.Value(requestHostKey).(string) | 
					
						
							|  |  |  | 	if ok { | 
					
						
							|  |  |  | 		return v | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return "" | 
					
						
							|  |  |  | } |