Skip to content

Instantly share code, notes, and snippets.

@mrkplt mrkplt/end_point.go
Created Jun 18, 2015

Embed
What would you like to do?
package main
import (
"net/http"
"github.com/mrkplt/end_point/models"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write(models.User{FirstName: "Mark"}.Json())
})
http.ListenAndServe(":8080", nil)
}
package models
import "encoding/json"
type User struct {
FirstName string `json:"first_name"`
}
func (u User) Json() (r []byte) {
r, _ = json.Marshal(&u)
return r
}
@BeerInHand

This comment has been minimized.

Copy link

commented Jun 19, 2015

that's pretty nice - i'll have to play around with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.