|
1 | 1 | package main |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "errors" |
5 | 4 | "fmt" |
6 | | - "net/http" |
7 | | - "os" |
8 | | - |
9 | | - "github.com/rs/cors" |
10 | 5 | ) |
11 | 6 |
|
12 | | -func main() { |
13 | | - mux := http.NewServeMux() |
14 | | - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { |
15 | | - fmt.Printf("got / request from %s\n", r.RemoteAddr) |
16 | | - w.Header().Set("Content-Type", "application/json") |
17 | | - _, err := w.Write([]byte(greeting())) |
18 | | - if err != nil { |
19 | | - panic(err) |
20 | | - } |
21 | | - }) |
22 | | - |
23 | | - c := cors.New(cors.Options{ |
24 | | - AllowedOrigins: []string{ |
25 | | - "http://greetings.kylepenfound.com", |
26 | | - "https://dagger-demo.netlify.app", |
27 | | - "http://localhost:8081", |
28 | | - "http://localhost:1313", |
29 | | - }, |
30 | | - // Enable Debugging for testing, consider disabling in production |
31 | | - Debug: true, |
32 | | - }) |
33 | | - handler := c.Handler(mux) |
34 | | - err := http.ListenAndServe(":8080", handler) |
35 | | - if errors.Is(err, http.ErrServerClosed) { |
36 | | - fmt.Printf("server closed\n") |
37 | | - } else if err != nil { |
38 | | - fmt.Printf("error starting server: %s\n", err) |
39 | | - os.Exit(1) |
40 | | - } |
| 7 | +type Person struct { |
| 8 | + Name string |
41 | 9 | } |
42 | 10 |
|
43 | | -func greeting() string { |
44 | | - greeting := "Greetings Daggernauts!" |
45 | | - return fmt.Sprintf("{\"greeting\":\"%s\"}", greeting) |
| 11 | +func main() { |
| 12 | + var Marvin = Person{Name: "Marvin"} |
| 13 | + fmt.Println("Hello, " + Marvin.Name + "!") |
46 | 14 | } |
0 commit comments