mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-11 02:48:21 +00:00
22 lines
448 B
Go
22 lines
448 B
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
"runtime/debug"
|
|
|
|
"golang.org/x/exp/slog"
|
|
)
|
|
|
|
func HandleAPI(w http.ResponseWriter, r *http.Request) {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
slog.Error("Recovered Panic Handling HTTP API Request", fmt.Errorf("%v", r), "stack", debug.Stack())
|
|
}
|
|
}()
|
|
err := apiHandler.HandleRequest(context.TODO(), r.Body, w)
|
|
if err != nil {
|
|
slog.Error("Handling HTTP API Request", err)
|
|
}
|
|
}
|