| 
									
										
										
										
											2018-08-07 11:56:55 +02:00
										 |  |  | package http | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"context" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/ethereum/go-ethereum/swarm/api" | 
					
						
							|  |  |  | 	"github.com/ethereum/go-ethereum/swarm/sctx" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-06 17:54:19 +09:00
										 |  |  | type uriKey struct{} | 
					
						
							| 
									
										
										
										
											2018-08-07 11:56:55 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | func GetRUID(ctx context.Context) string { | 
					
						
							| 
									
										
										
										
											2018-11-06 17:54:19 +09:00
										 |  |  | 	v, ok := ctx.Value(sctx.HTTPRequestIDKey{}).(string) | 
					
						
							| 
									
										
										
										
											2018-08-07 11:56:55 +02:00
										 |  |  | 	if ok { | 
					
						
							|  |  |  | 		return v | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return "xxxxxxxx" | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func SetRUID(ctx context.Context, ruid string) context.Context { | 
					
						
							| 
									
										
										
										
											2018-11-06 17:54:19 +09:00
										 |  |  | 	return context.WithValue(ctx, sctx.HTTPRequestIDKey{}, ruid) | 
					
						
							| 
									
										
										
										
											2018-08-07 11:56:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func GetURI(ctx context.Context) *api.URI { | 
					
						
							| 
									
										
										
										
											2018-11-06 17:54:19 +09:00
										 |  |  | 	v, ok := ctx.Value(uriKey{}).(*api.URI) | 
					
						
							| 
									
										
										
										
											2018-08-07 11:56:55 +02:00
										 |  |  | 	if ok { | 
					
						
							|  |  |  | 		return v | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func SetURI(ctx context.Context, uri *api.URI) context.Context { | 
					
						
							| 
									
										
										
										
											2018-11-06 17:54:19 +09:00
										 |  |  | 	return context.WithValue(ctx, uriKey{}, uri) | 
					
						
							| 
									
										
										
										
											2018-08-07 11:56:55 +02:00
										 |  |  | } |