mirror of
https://github.com/kaaninchen/Laterna.git
synced 2026-09-17 19:12:48 +00:00
database setup and getcurrent
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/siestaw/laterna/server/cmd/internal/models"
|
||||
)
|
||||
|
||||
func HTTPErrorHandling(w http.ResponseWriter, r *http.Request, status int, message string) {
|
||||
timestamp := time.Now().Format("2006-01-02_15-04-05")
|
||||
errResp := models.HTTPError{
|
||||
Timestamp: timestamp,
|
||||
Status: status,
|
||||
Error: http.StatusText(status),
|
||||
Message: message,
|
||||
Path: r.URL.Path,
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(status)
|
||||
json.NewEncoder(w).Encode(errResp)
|
||||
}
|
||||
Reference in New Issue
Block a user