Return 404 always on error
This commit is contained in:
		
							parent
							
								
									4511c4c017
								
							
						
					
					
						commit
						9ed3fcd793
					
				
							
								
								
									
										4
									
								
								gitea.go
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								gitea.go
									
									
									
									
									
								
							@ -1,9 +1,7 @@
 | 
				
			|||||||
package gitea
 | 
					package gitea
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"errors"
 | 
					 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"io/fs"
 | 
					 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -75,10 +73,8 @@ func (m Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request, _ caddyhtt
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	f, err := m.Client.Open(fp, r.URL.Query().Get("ref"))
 | 
						f, err := m.Client.Open(fp, r.URL.Query().Get("ref"))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, fs.ErrNotExist) {
 | 
					 | 
				
			||||||
		return caddyhttp.Error(http.StatusNotFound, err)
 | 
							return caddyhttp.Error(http.StatusNotFound, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_, err = io.Copy(w, f)
 | 
						_, err = io.Copy(w, f)
 | 
				
			||||||
	return err
 | 
						return err
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user