flutter frontend initial commit
This commit is contained in:
+1
-47
@@ -26,50 +26,4 @@ func main() {
|
||||
}
|
||||
|
||||
http.ListenAndServe(":"+port, r)
|
||||
}
|
||||
|
||||
/*package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Message struct {
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// POST method handler
|
||||
func createUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var user User
|
||||
// decode json from request body
|
||||
err := json.NewDecoder(r.Body).Decode(&user)
|
||||
if err != nil {
|
||||
http.Error(w, "invalid JSON", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
response := Message{Text: "User created: " + user.Name}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
// handler function
|
||||
func helloHandler(w http.ResponseWriter, r *http.Request) {
|
||||
response := Message{Text: "Hellow from Go API!"}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/hello", helloHandler)
|
||||
http.HandleFunc("/createUser", createUserHandler)
|
||||
fmt.Println("server running on http://localhost:8080")
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}*/
|
||||
}
|
||||
Reference in New Issue
Block a user