mirror of
https://github.com/kaaninchen/Laterna.git
synced 2026-09-17 19:12:48 +00:00
feat: a lot
i did a lot of work, and i also forgot to add commits regularly. I added the controller routes to create and delete controllers, improved error handling und improved the authentification process. I'm gonna add an websocket next and then I should be hopefully done with the foundations of this project. I may also add anviewControllers route which respons with every available controller
This commit is contained in:
+3
-4
@@ -31,7 +31,6 @@ func IsValidHexColor(color string) bool {
|
||||
return match
|
||||
}
|
||||
|
||||
|
||||
func GenerateToken() (string, error) {
|
||||
bytes := make([]byte, 32)
|
||||
if _, err := rand.Read(bytes); err != nil {
|
||||
@@ -50,12 +49,12 @@ func ValidateToken(providedToken string, storedHash string) bool {
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func HTTPErrorHandling(w http.ResponseWriter, r *http.Request, status int, message string) {
|
||||
func HTTPResponseHandler(w http.ResponseWriter, r *http.Request, status int, message string) {
|
||||
timestamp := time.Now().Format("2006-01-02_15-04-05")
|
||||
errResp := models.HTTPError{
|
||||
errResp := models.HTTPResponse{
|
||||
Timestamp: timestamp,
|
||||
Status: status,
|
||||
Error: http.StatusText(status),
|
||||
Text: http.StatusText(status),
|
||||
Message: message,
|
||||
Path: r.URL.Path,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user