Prześlij pliki do ''

This commit is contained in:
Robert Stachecki 2018-11-20 21:30:03 +00:00
parent 0abe41e87b
commit 88037849e1

11
serwer.go Normal file
View File

@ -0,0 +1,11 @@
func main() {
db := database{"buty": 50, "skarpety": 5}
log.Fatal(http.ListenAndServe("localhost:8000", db))
}
type dollars float32
func (d dollars) String() string { return fmt.Sprintf("%.2f PLN", d) }
type database map[string]dollars
func (db database) ServeHTTP(w http.ResponseWriter, req *http.Request) {
for item, price := range db {
fmt.Fprintf(w, "%s: %s\n", item, price)
}