putting web from main into this branch
This commit is contained in:
32
pkg/web/server/server.go
Normal file
32
pkg/web/server/server.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/LazyBachelor/LazyPM/internal/service"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
Address string
|
||||
Assets embed.FS
|
||||
Services *service.Services
|
||||
}
|
||||
|
||||
// NewServer creates and configures a new HTTP server instance.
|
||||
func NewServer(props Server) *http.Server {
|
||||
if props.Address == "" {
|
||||
props.Address = ":8080"
|
||||
}
|
||||
|
||||
handler := props.RegisterRoutes(props.Assets)
|
||||
|
||||
return &http.Server{
|
||||
Addr: props.Address,
|
||||
Handler: handler,
|
||||
IdleTimeout: time.Minute,
|
||||
ReadTimeout: time.Second * 10,
|
||||
WriteTimeout: time.Second * 10,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user