mirror of
				https://github.com/ClusterCockpit/cc-backend
				synced 2025-11-04 01:25:06 +01:00 
			
		
		
		
	chore: Add 404 page for not found routes
This commit is contained in:
		
							
								
								
									
										15
									
								
								build.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								build.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
TARGET="./cc-backend"
 | 
			
		||||
VAR="./var"
 | 
			
		||||
CFG="config.json .env"
 | 
			
		||||
FRONTEND="./web/frontend"
 | 
			
		||||
VERSION="1.2.2"
 | 
			
		||||
GIT_HASH=$(git rev-parse --short HEAD || echo 'development')
 | 
			
		||||
CURRENT_TIME=$(date +"%Y-%m-%d:T%H:%M:%S")
 | 
			
		||||
LD_FLAGS="-s -X main.date=${CURRENT_TIME} -X main.version=${VERSION} -X main.commit=${GIT_HASH}"
 | 
			
		||||
 | 
			
		||||
echo  ${LD_FLAGS}
 | 
			
		||||
 | 
			
		||||
# build.sh
 | 
			
		||||
go build -ldflags="${LD_FLAGS}" ./cmd/cc-backend
 | 
			
		||||
@@ -337,6 +337,11 @@ func main() {
 | 
			
		||||
		rw.Header().Add("Content-Type", "text/html; charset=utf-8")
 | 
			
		||||
		web.RenderTemplate(rw, "privacy.tmpl", &web.Page{Title: "Privacy", Build: buildInfo})
 | 
			
		||||
	})
 | 
			
		||||
	r.NotFoundHandler = http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		rw.WriteHeader(http.StatusNotFound)
 | 
			
		||||
		rw.Header().Add("Content-Type", "text/html; charset=utf-8")
 | 
			
		||||
		web.RenderTemplate(rw, "404.tmpl", &web.Page{Title: "Page not found", Build: buildInfo})
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	secured := r.PathPrefix("/").Subrouter()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1014
									
								
								web/frontend/pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1014
									
								
								web/frontend/pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user