common/http: rename to common/httpserver

This is a preparation to introduce an httpclient common package. And it
makes it easier to use http from the standard library.
This commit is contained in:
Vincent Bernat
2023-05-28 09:08:07 +02:00
parent 1c56fd1505
commit 62521e629d
32 changed files with 121 additions and 120 deletions

View File

@@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: 2022 Free Mobile
// SPDX-License-Identifier: AGPL-3.0-only
//go:build !release
package httpserver
import (
"testing"
"akvorado/common/daemon"
"akvorado/common/helpers"
"akvorado/common/reporter"
)
// NewMock create a new HTTP component listening on a random free port.
func NewMock(t *testing.T, r *reporter.Reporter) *Component {
t.Helper()
config := DefaultConfiguration()
config.Listen = "127.0.0.1:0"
c, err := New(r, config, Dependencies{Daemon: daemon.NewMock(t)})
if err != nil {
t.Fatalf("New() error:\n%+v", err)
}
helpers.StartStop(t, c)
return c
}