28 lines
		
	
	
		
			544 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			544 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package main
 | |
| 
 | |
| import (
 | |
| 	"go-udemy-web-1/pkg/config"
 | |
| 	"go-udemy-web-1/pkg/handlers"
 | |
| 	"net/http"
 | |
| 
 | |
| 	"github.com/go-chi/chi/v5"
 | |
| 	"github.com/go-chi/chi/v5/middleware"
 | |
| )
 | |
| 
 | |
| func routes(app *config.AppConfig) http.Handler {
 | |
| 	mux := chi.NewMux()
 | |
| 
 | |
| 	mux.Use(middleware.Recoverer)
 | |
| 	mux.Use(WriteToConsole)
 | |
| 	mux.Use(NoSurf)
 | |
| 	mux.Use(SessionLoad)
 | |
| 
 | |
| 	mux.Get("/", handlers.Repo.Home)
 | |
| 	mux.Get("/about", handlers.Repo.About)
 | |
| 
 | |
| 	fileServer := http.FileServer(http.Dir("./static/"))
 | |
| 	mux.Handle("/static/*", http.StripPrefix("/static", fileServer))
 | |
| 
 | |
| 	return mux
 | |
| }
 |