diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/git_toolbox_blame.xml b/.idea/git_toolbox_blame.xml new file mode 100644 index 0000000..7dc1249 --- /dev/null +++ b/.idea/git_toolbox_blame.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/httpserver.iml b/.idea/httpserver.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/httpserver.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml new file mode 100644 index 0000000..9fac092 --- /dev/null +++ b/.idea/material_theme_project_new.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..259cee6 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..7e182b4 --- /dev/null +++ b/main.go @@ -0,0 +1,33 @@ +package main + +import ( + "errors" + "fmt" + "io" + "net/http" + "os" +) + +func getRoot(w http.ResponseWriter, r *http.Request) { + fmt.Printf("Request received: \n") + io.WriteString(w, "This is my first web server. \n") +} + +func getHello(w http.ResponseWriter, r *http.Request) { + fmt.Printf("Hello request received: \n") + io.WriteString(w, "Hello, World! \n") +} + +func main() { + http.HandleFunc("/", getRoot) + http.HandleFunc("/hello", getHello) + + err := http.ListenAndServe(":8080", nil) + if errors.Is(err, http.ErrServerClosed) { + fmt.Printf("Server Closed! \n") + } else if err != nil { + fmt.Printf("Error: %v \n", err) + os.Exit(1) + } + fmt.Printf("Server started! \n") +}