-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
32 lines (26 loc) · 870 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Test various ways to do HTTP method+path routing in Go
// Each router handles the 11 URLs below:
//
// GET / # home
// GET /contact # contact
// GET /api/widgets # apiGetWidgets
// POST /api/widgets # apiCreateWidget
// POST /api/widgets/:slug # apiUpdateWidget
// POST /api/widgets/:slug/parts # apiCreateWidgetPart
// POST /api/widgets/:slug/parts/:id/update # apiUpdateWidgetPart
// POST /api/widgets/:slug/parts/:id/delete # apiDeleteWidgetPart
// GET /:slug # widget
// GET /:slug/admin # widgetAdmin
// POST /:slug/image # widgetImage
package main
import (
"fmt"
"log"
"net/http"
)
const port = 9990
func main() {
router := Serve // In route.go file
fmt.Printf("listening on port %d\n", port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), router))
}