Compare commits
4 Commits
c5358e6c50
...
8d0cd0fd1b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d0cd0fd1b | ||
|
|
35ec6678f8 | ||
|
|
ac20f9172d | ||
|
|
b96f65c294 |
@@ -20,7 +20,7 @@ A simple, lightweight web application for managing user profile photos in a Free
|
|||||||
1. **Clone the Repository**
|
1. **Clone the Repository**
|
||||||
```bash
|
```bash
|
||||||
git clone https://git.astraltech.xyz/gawells/Self-Service-Dashboard
|
git clone https://git.astraltech.xyz/gawells/Self-Service-Dashboard
|
||||||
cd account-manager
|
cd Self-Service-Dashboard
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Configure the Application**
|
2. **Configure the Application**
|
||||||
@@ -39,7 +39,7 @@ A simple, lightweight web application for managing user profile photos in a Free
|
|||||||
|
|
||||||
5. **Run the Server**
|
5. **Run the Server**
|
||||||
```bash
|
```bash
|
||||||
go run src/*.go
|
go run ./src/main/
|
||||||
```
|
```
|
||||||
The application will be available at `http://<host>:<port>`.
|
The application will be available at `http://<host>:<port>`.
|
||||||
|
|
||||||
|
|||||||
27
src/logging/logging.go
Normal file
27
src/logging/logging.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package logging
|
||||||
|
|
||||||
|
import "log"
|
||||||
|
|
||||||
|
type EventType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
ReadFile EventType = iota
|
||||||
|
)
|
||||||
|
|
||||||
|
func Info(message string) {
|
||||||
|
log.Print(message)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Infof(message string, vars ...any) {
|
||||||
|
log.Printf(message, vars...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Event(eventType EventType, eventData ...any) {
|
||||||
|
switch eventType {
|
||||||
|
case ReadFile:
|
||||||
|
{
|
||||||
|
log.Printf("Reading file %s", eventData[0])
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/main/helpers.go
Normal file
17
src/main/helpers.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"astraltech.xyz/accountmanager/src/logging"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ReadFile(path string) ([]byte, error) {
|
||||||
|
logging.Event(logging.ReadFile, "static/blank_profile.jpg")
|
||||||
|
data, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
logging.Infof("Could not read file at %s", path)
|
||||||
|
}
|
||||||
|
logging.Infof("Successfully read file at %s", path)
|
||||||
|
return data, err
|
||||||
|
}
|
||||||
@@ -11,6 +11,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"astraltech.xyz/accountmanager/src/logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -170,7 +172,7 @@ func avatarHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
filePath := fmt.Sprintf("./avatars/%s.jpeg", username)
|
filePath := fmt.Sprintf("./avatars/%s.jpeg", username)
|
||||||
cleaned := filepath.Clean(filePath)
|
cleaned := filepath.Clean(filePath)
|
||||||
value, err := os.ReadFile(cleaned)
|
value, err := ReadFile(cleaned)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
photoCreatedMutex.Lock()
|
photoCreatedMutex.Lock()
|
||||||
@@ -306,9 +308,10 @@ func cleanupSessions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var err error = nil
|
logging.Info("Starting the server")
|
||||||
|
|
||||||
blankPhotoData, err = os.ReadFile("static/blank_profile.jpg")
|
var err error = nil
|
||||||
|
blankPhotoData, err = ReadFile("static/blank_profile.jpg")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Could not load blank profile image")
|
log.Fatal("Could not load blank profile image")
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user