b2 #1
5
.env
5
.env
|
@ -1,5 +0,0 @@
|
||||||
PORT=4008
|
|
||||||
# URL_PREFIX=http://0.0.0.0:8000/image_asset
|
|
||||||
URL_PREFIX = https://minio-api.3027622.siliconpin.com/image-asset/image_asset/
|
|
||||||
|
|
||||||
# https://minio-api.3027622.siliconpin.com/image-asset/image_asset/20220818222344367.jpg
|
|
|
@ -1 +1,2 @@
|
||||||
image_asset
|
image_asset
|
||||||
|
.env
|
19
main.go
19
main.go
|
@ -12,7 +12,6 @@ import (
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/rs/cors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
@ -111,29 +110,13 @@ func saveImageNames() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func serveAPI() {
|
func serveAPI() {
|
||||||
// Create a new CORS handler
|
|
||||||
c := cors.New(cors.Options{
|
|
||||||
AllowedOrigins: []string{
|
|
||||||
"http://localhost:4321",
|
|
||||||
"https://siliconpin.cs1.hz.siliconpin.com",
|
|
||||||
"https://siliconpin.com",
|
|
||||||
},
|
|
||||||
AllowedMethods: []string{"GET", "POST", "OPTIONS"},
|
|
||||||
AllowedHeaders: []string{"Content-Type"},
|
|
||||||
AllowCredentials: true,
|
|
||||||
// Debug: true, // Remove in production
|
|
||||||
})
|
|
||||||
|
|
||||||
// Create a new mux router
|
// Create a new mux router
|
||||||
router := http.NewServeMux()
|
router := http.NewServeMux()
|
||||||
router.HandleFunc("/get-image", getImageHandler)
|
router.HandleFunc("/get-image", getImageHandler)
|
||||||
router.HandleFunc("/save-score", saveScoreHandler)
|
router.HandleFunc("/save-score", saveScoreHandler)
|
||||||
|
|
||||||
// Wrap your router with the CORS handler
|
|
||||||
handler := c.Handler(router)
|
|
||||||
|
|
||||||
log.Printf("Server starting on port %s", config.Port)
|
log.Printf("Server starting on port %s", config.Port)
|
||||||
log.Fatal(http.ListenAndServe("0.0.0.0:"+config.Port, handler))
|
log.Fatal(http.ListenAndServe(":"+config.Port, router))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getImageHandler(w http.ResponseWriter, r *http.Request) {
|
func getImageHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
Loading…
Reference in New Issue