Files
thamanyah/cms/main.go
T
FahdShalhoub 32506730c7
Build, Push and Deploy CMS / build-push-deploy (push) Failing after 4m15s
TEST: Pipeline
2026-08-16 19:26:51 +03:00

54 lines
1.4 KiB
Go

package main
import (
"context"
"fmt"
"log"
"net/http"
"thamanyah/cms/v2/internal/handlers"
"thamanyah/cms/v2/internal/services"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/mediaconvert"
"github.com/aws/aws-sdk-go-v2/service/s3"
)
func main() {
config, err := config.LoadDefaultConfig(context.TODO())
if err != nil {
panic(fmt.Errorf("failed To Load S3 Config: %s", err))
}
concreteS3Client := &services.S3Concrete{
S3Client: s3.NewFromConfig(config),
Bucket: "",
}
concreteS3Client.AssertSuccessfulConnection(context.Background())
services.S3Client = concreteS3Client
services.MediaConvertClient = &services.MediaConvertConcrete{
MediaConvertClient: mediaconvert.NewFromConfig(config),
Role: "test",
InputBucket: "",
OutputBucket: "",
}
mux := http.NewServeMux()
mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
mux.HandleFunc("GET /", handlers.Home)
mux.HandleFunc("GET /api/hello", handlers.Hello)
mux.HandleFunc("GET /health", handlers.Health)
mux.HandleFunc("GET /videos/new", handlers.NewVideo)
mux.HandleFunc("POST /videos/presign", handlers.PresignVideoUpload)
mux.HandleFunc("POST /videos", handlers.CompleteVideoUpload)
addr := ":8081"
log.Printf("listening on %s", addr)
if err := http.ListenAndServe(addr, mux); err != nil {
log.Fatal(err)
}
}