Use common httpserver across fission (#2409)

* Defining httpserver package to capture httpserver shutdown and
introduces uniform running of http server across codebase.
* Add unit tests for httpserver

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Sanket Sudake
2022-04-14 11:35:58 +05:30
committed by GitHub
parent b638a6d047
commit 8442e21621
18 changed files with 139 additions and 93 deletions
+4 -2
View File
@@ -17,15 +17,17 @@ limitations under the License.
package app
import (
"context"
"net/http"
"go.uber.org/zap"
builder "github.com/fission/fission/pkg/builder"
"github.com/fission/fission/pkg/utils/httpserver"
)
// Usage: builder <shared volume path>
func Run(logger *zap.Logger, shareVolume string) error {
func Run(ctx context.Context, logger *zap.Logger, shareVolume string) {
builder := builder.MakeBuilder(logger, shareVolume)
mux := http.NewServeMux()
mux.HandleFunc("/", builder.Handler)
@@ -33,5 +35,5 @@ func Run(logger *zap.Logger, shareVolume string) error {
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})
return http.ListenAndServe(":8001", mux)
httpserver.StartServer(ctx, logger, "builder", "8001", mux)
}