Honor the useStaticDirectory variable in the static handler to minimize unnecessary os.Stat
This commit is contained in:
		
							parent
							
								
									1cf9318bc8
								
							
						
					
					
						commit
						63f484e269
					
				
					 1 changed files with 8 additions and 3 deletions
				
			
		
							
								
								
									
										5
									
								
								pkg.go
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								pkg.go
									
										
									
									
									
								
							|  | @ -305,12 +305,17 @@ func (service *Service) StaticHandler(w http.ResponseWriter, r *http.Request, se | |||
| 
 | ||||
| 		r.URL.Path = fmt.Sprintf("/%s/%s", comp[1], comp[2]) | ||||
| 		p := fmt.Sprintf(service.staticDirectory+"/%s/%s", comp[1], comp[2]) | ||||
| 
 | ||||
| 		if service.useStaticDirectory { | ||||
| 			_, err = os.Stat(p) | ||||
| 			if err == nil { | ||||
| 				service.staticLocalFileserver.ServeHTTP(w, r) | ||||
| 			} else { | ||||
| 				service.staticEmbeddedFileserver.ServeHTTP(w, r) | ||||
| 			} | ||||
| 		} else { | ||||
| 			service.staticEmbeddedFileserver.ServeHTTP(w, r) | ||||
| 		} | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue