diff --git a/build/.keep b/build/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cmd/thunderlight/thunderlight.go b/cmd/thunderlight/thunderlight.go new file mode 100644 index 0000000..da29a2c --- /dev/null +++ b/cmd/thunderlight/thunderlight.go @@ -0,0 +1,4 @@ +package main + +func main() { +} diff --git a/deployment/.keep b/deployment/.keep new file mode 100644 index 0000000..e69de29 diff --git a/go.mod b/go.mod index e369f7e..41d3617 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,3 @@ module github.com/thunderlight-shogi/engine go 1.22.0 - -require github.com/gorilla/mux v1.8.1 diff --git a/go.sum b/go.sum index 7128337..e69de29 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +0,0 @@ -github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= -github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= diff --git a/internal/database/.keep b/internal/database/.keep new file mode 100644 index 0000000..e69de29 diff --git a/engine/engine.go b/internal/engine/engine.go similarity index 100% rename from engine/engine.go rename to internal/engine/engine.go diff --git a/main.go b/main.go deleted file mode 100644 index 46a128e..0000000 --- a/main.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "github.com/thunderlight-shogi/engine/website" - -func main() { - website.RunServer() -} diff --git a/website/.keep b/website/.keep new file mode 100644 index 0000000..e69de29 diff --git a/website/controllers/editor.go b/website/controllers/editor.go deleted file mode 100644 index 070e03e..0000000 --- a/website/controllers/editor.go +++ /dev/null @@ -1,17 +0,0 @@ -package website - -import ( - "fmt" - "io" - "net/http" -) - -func Editor(response http.ResponseWriter, request *http.Request, parameters map[string]string) { - id, ok := parameters["id"] - - if !ok { - io.WriteString(response, "ID should be set.") - } - - io.WriteString(response, fmt.Sprintf("ID is %s", id)) -} diff --git a/website/controllers/home.go b/website/controllers/home.go deleted file mode 100644 index be700b5..0000000 --- a/website/controllers/home.go +++ /dev/null @@ -1,10 +0,0 @@ -package website - -import ( - "io" - "net/http" -) - -func Home(response http.ResponseWriter, request *http.Request, parameters map[string]string) { - io.WriteString(response, "

It works!

") -} diff --git a/website/route.go b/website/route.go deleted file mode 100644 index 8b7c37c..0000000 --- a/website/route.go +++ /dev/null @@ -1,31 +0,0 @@ -package website - -import ( - "net/http" - - "github.com/gorilla/mux" -) - -type route struct { - method string - pattern string - handler ParametrizedHttpHandlerFunc -} - -type HttpParameters = map[string]string -type ParametrizedHttpHandlerFunc = func(response http.ResponseWriter, request *http.Request, parameters HttpParameters) - -func createRoute(method string, pattern string, handler ParametrizedHttpHandlerFunc) route { - return route{method, pattern, handler} -} - -func Get(pattern string, handler ParametrizedHttpHandlerFunc) route { - return createRoute("GET", pattern, handler) -} - -func WrapHandler(handler ParametrizedHttpHandlerFunc) http.HandlerFunc { - return func(response http.ResponseWriter, request *http.Request) { - var parameters HttpParameters = mux.Vars(request) - handler(response, request, parameters) - } -} diff --git a/website/routes.go b/website/routes.go deleted file mode 100644 index 9edb5c1..0000000 --- a/website/routes.go +++ /dev/null @@ -1,8 +0,0 @@ -package website - -import website "github.com/thunderlight-shogi/engine/website/controllers" - -var Routes = []route{ - Get("/", website.Home), - Get("/editor/{id}", website.Editor), -} diff --git a/website/server.go b/website/server.go deleted file mode 100644 index 5658ea0..0000000 --- a/website/server.go +++ /dev/null @@ -1,22 +0,0 @@ -package website - -import ( - "fmt" - "net/http" - - "github.com/gorilla/mux" -) - -const port int = 9999 - -func RunServer() { - router := mux.NewRouter() - - for _, route := range Routes { - fmt.Printf("⚙️ The %s %s route is added.\n", route.method, route.pattern) - router.HandleFunc(route.pattern, WrapHandler(route.handler)) - } - - fmt.Printf("✅ The server is running at http://localhost:%d.\n", port) - http.ListenAndServe(fmt.Sprintf(":%d", port), router) -}