aboutsummaryrefslogtreecommitdiff
path: root/http_server.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-02-12 00:17:29 +0700
committerShulhan <ms@kilabit.info>2026-02-12 01:29:15 +0700
commitff5a7ecdb8aa0ccfe4bd4f71648e7254e470c930 (patch)
tree20f64fff336b5881b3db03db2052b209fefd23c3 /http_server.go
parent2686a70d0eeb14c0eba68f449658827e144e75a2 (diff)
downloadawwan-ff5a7ecdb8aa0ccfe4bd4f71648e7254e470c930.tar.xz
all: change Serve parameters to struct `ServeOptions`
In case we needs to add another parameter, which will do later, the argument will be too long. Using parameters is acceptable only for 2 to 3 arguments.
Diffstat (limited to 'http_server.go')
-rw-r--r--http_server.go20
1 files changed, 5 insertions, 15 deletions
diff --git a/http_server.go b/http_server.go
index e0935c5..cc88798 100644
--- a/http_server.go
+++ b/http_server.go
@@ -1,5 +1,5 @@
-// SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info>
// SPDX-License-Identifier: GPL-3.0-or-later
+// SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info>
package awwan
@@ -11,7 +11,6 @@ import (
"fmt"
"io/fs"
"log"
- "net"
"net/http"
"os"
"path"
@@ -41,9 +40,6 @@ const (
paramNameID = `id`
)
-// DefListenAddress default HTTP server address to serve WUI.
-const DefListenAddress = `127.0.0.1:17600`
-
// httpServer awwan HTTP server for HTTP API and web user interface feature.
type httpServer struct {
*libhttp.Server
@@ -63,10 +59,8 @@ type httpServer struct {
// newHTTPServer create and initialize HTTP server to serve awwan HTTP API
// and web user interface.
-func newHTTPServer(aww *Awwan, listener net.Listener, address string) (httpd *httpServer, err error) {
- var (
- logp = `newHTTPServer`
- )
+func newHTTPServer(aww *Awwan, serveOpts ServeOptions) (httpd *httpServer, err error) {
+ var logp = `newHTTPServer`
httpd = &httpServer{
idExecRes: make(map[string]*ExecResponse),
@@ -92,13 +86,9 @@ func newHTTPServer(aww *Awwan, listener net.Listener, address string) (httpd *ht
return nil, fmt.Errorf(`%s: %w`, logp, err)
}
- var serverOpts = libhttp.ServerOptions{
- Listener: listener,
- Memfs: internal.MemfsWui,
- Address: address,
- }
+ serveOpts.Memfs = internal.MemfsWui
- httpd.Server, err = libhttp.NewServer(serverOpts)
+ httpd.Server, err = libhttp.NewServer(serveOpts.ServerOptions)
if err != nil {
return nil, fmt.Errorf(`%s: %w`, logp, err)
}