Prześlij pliki do ''
This commit is contained in:
parent
0abe41e87b
commit
88037849e1
11
serwer.go
Normal file
11
serwer.go
Normal 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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user