Go start
This commit is contained in:
commit
3ce6b96597
8
go.mod
Normal file
8
go.mod
Normal file
@ -0,0 +1,8 @@
|
||||
module git.araozu.dev/card-jong-be
|
||||
|
||||
go 1.22.2
|
||||
|
||||
require (
|
||||
github.com/gorilla/mux v1.8.1 // indirect
|
||||
github.com/rs/cors v1.11.0 // indirect
|
||||
)
|
4
go.sum
Normal file
4
go.sum
Normal file
@ -0,0 +1,4 @@
|
||||
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
||||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
||||
github.com/rs/cors v1.11.0 h1:0B9GE/r9Bc2UxRMMtymBkHTenPkHDv0CW4Y98GBY+po=
|
||||
github.com/rs/cors v1.11.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
|
45
main.go
Normal file
45
main.go
Normal file
@ -0,0 +1,45 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/rs/cors"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("hello SEKAI!!")
|
||||
router := mux.NewRouter().PathPrefix("/api").Subrouter()
|
||||
|
||||
router.HandleFunc("/register", Register)
|
||||
|
||||
port, ok := os.LookupEnv("PORT")
|
||||
if !ok {
|
||||
port = "8080"
|
||||
}
|
||||
|
||||
cors := cors.New(cors.Options{
|
||||
AllowedOrigins: []string{"http://localhost:3000"},
|
||||
AllowedMethods: []string{"GET", "DELETE", "POST", "PUT", "OPTIONS"},
|
||||
AllowedHeaders: []string{"Content-Type", "Origin", "Accept", "Authorization"},
|
||||
AllowCredentials: true,
|
||||
})
|
||||
|
||||
handler := cors.Handler(router)
|
||||
|
||||
log.Fatal(http.ListenAndServe(":"+port, handler))
|
||||
}
|
||||
|
||||
type PersonInfo struct {
|
||||
useruuid int
|
||||
username string
|
||||
}
|
||||
|
||||
func Register(writer http.ResponseWriter, request *http.Request) {
|
||||
writer.Header().Set("Content-Type", "application/json")
|
||||
writer.WriteHeader(http.StatusOK)
|
||||
fmt.Fprintf(writer, "{\"yes\":\"and\"}")
|
||||
}
|
Loading…
Reference in New Issue
Block a user