File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -6,14 +6,16 @@ import (
66	"time" 
77)
88
9- // Handler returns an http handler that requires a  "seconds" query argument  
10- // and produces a profile over this duration. The optional "format" parameter  
11- // controls if the output is written in Google's "pprof" format (default) or  
12- // Brendan Gregg's "folded" stack format. 
9+ // Handler returns an http handler that takes an optional  "seconds" query 
10+ // argument that defaults to "30"  and produces a profile over this duration. 
11+ // The optional "format" parameter  controls if the output is written in 
12+ // Google's "pprof" format (default) or  Brendan Gregg's "folded" stack format. 
1313func  Handler () http.Handler  {
1414	return  http .HandlerFunc (func (w  http.ResponseWriter , r  * http.Request ) {
1515		var  seconds  int 
16- 		if  _ , err  :=  fmt .Sscanf (r .URL .Query ().Get ("seconds" ), "%d" , & seconds ); err  !=  nil  {
16+ 		if  s  :=  r .URL .Query ().Get ("seconds" ); s  ==  ""  {
17+ 			seconds  =  30 
18+ 		} else  if  _ , err  :=  fmt .Sscanf (s , "%d" , & seconds ); err  !=  nil  ||  seconds  <=  0  {
1719			w .WriteHeader (http .StatusBadRequest )
1820			fmt .Fprintf (w , "bad seconds: %d: %s\n " , seconds , err )
1921		}
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments