Created
September 12, 2015 07:54
-
-
Save Burning-Chai/20cd719e9986aadd23e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"encoding/json" | |
) | |
type Student struct { | |
Id int | |
Name string | |
Class string | |
} | |
func main() { | |
fmt.Println("Server running!!!") | |
http.HandleFunc("/hello", helloHandler) | |
} | |
func helloHandler(rw http.ResponseWriter, req *http.Request) { | |
students := []Student{ | |
{Id:1, Name:"Yanou", Class:"1A"}, | |
{Id:2, Name:"Tanaka", Class:"1B"}, | |
} | |
data, _ := json.Marshal(students) | |
rw.Write(data) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment