feat: initial commit
This commit is contained in:
27
internal/setup/http_server.go
Normal file
27
internal/setup/http_server.go
Normal file
@ -0,0 +1,27 @@
|
||||
package setup
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"forge.cadoles.com/wpetit/kouiz/internal/config"
|
||||
"forge.cadoles.com/wpetit/kouiz/internal/http"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func NewHTTPServerFromConfig(ctx context.Context, conf *config.Config) (*http.Server, error) {
|
||||
// Configure Web UI handler
|
||||
webui, err := NewWebUIHandlerFromConfig(ctx, conf)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not configure webui handler from config")
|
||||
}
|
||||
|
||||
// Create HTTP server
|
||||
|
||||
server := http.NewServer(
|
||||
webui,
|
||||
http.WithAddress(conf.HTTP.Address),
|
||||
http.WithBaseURL(conf.HTTP.BaseURL),
|
||||
)
|
||||
|
||||
return server, nil
|
||||
}
|
Reference in New Issue
Block a user