fafda/internal/http/http.go
2024-12-19 01:41:46 +05:30

21 lines
419 B
Go

package http
import (
"net/http"
"github.com/rs/zerolog/log"
"github.com/spf13/afero"
"fafda/config"
)
func Serv(cfg config.HTTPServer, fs afero.Fs) error {
httpFs := afero.NewHttpFs(fs)
fileServer := http.FileServer(httpFs.Dir("/"))
http.Handle("/", fileServer)
log.Info().
Str("component", "httpserver").
Str("address", cfg.Addr).
Msg("starting server")
return http.ListenAndServe(cfg.Addr, nil)
}