feat: add build info endpoint
This commit is contained in:
		
							parent
							
								
									6d8df68954
								
							
						
					
					
						commit
						f6986afe76
					
				
							
								
								
									
										33
									
								
								cmd/ev/app.info.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								cmd/ev/app.info.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"net/http"
 | 
				
			||||||
 | 
						"runtime/debug"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"go.sour.is/pkg/lg"
 | 
				
			||||||
 | 
						"go.sour.is/pkg/service"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var _ = apps.Register(50, func(ctx context.Context, svc *service.Harness) error {
 | 
				
			||||||
 | 
						_, span := lg.Span(ctx)
 | 
				
			||||||
 | 
						defer span.End()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						svc.Add(&info{})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type info struct{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (info) RegisterHTTP(mux *http.ServeMux) {
 | 
				
			||||||
 | 
						mux.HandleFunc("/info", func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
							bi, ok := debug.ReadBuildInfo()
 | 
				
			||||||
 | 
							if !ok {
 | 
				
			||||||
 | 
								fmt.Fprint(w, "Build Info not avalible.")
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							fmt.Fprint(w, bi)
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user