File tree Expand file tree Collapse file tree 5 files changed +52
-2
lines changed Expand file tree Collapse file tree 5 files changed +52
-2
lines changed Original file line number Diff line number Diff line change 11package main
22
33import "fmt"
4+ import "net/http"
5+ import "os"
46
57func main () {
8+ registerRoutes ()
9+
610 fmt .Println ("Listen on 3000" )
11+ if err := http .ListenAndServe (":3000" , nil ); err != nil {
12+ fmt .Fprintf (os .Stderr , "ListenAndServe failed: %v" , err )
13+ os .Exit (1 )
14+ }
715}
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import "net/http"
4+
5+ func registerRoutes () {
6+
7+ http .HandleFunc ("/v1/categories/count" , func (w http.ResponseWriter , _ * http.Request ) {
8+ w .Write ([]byte ("TODO" ))
9+ })
10+
11+ http .HandleFunc ("/v1/collections/:collectionId/categories/count" , func (w http.ResponseWriter , _ * http.Request ) {
12+ w .Write ([]byte ("TODO" ))
13+ })
14+
15+ http .HandleFunc ("/v1/categories" , func (w http.ResponseWriter , _ * http.Request ) {
16+ w .Write ([]byte ("TODO" ))
17+ })
18+
19+ http .HandleFunc ("/v1/categories/:categoryId" , func (w http.ResponseWriter , _ * http.Request ) {
20+ w .Write ([]byte ("TODO" ))
21+ })
22+
23+ }
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ to install its dependencies and
133133afteward to run` ) ;
134134 } else if ( argv . lang === 'go' ) {
135135 console . info ( `Use
136- go run app .go
136+ go run * .go
137137or
138138 go build -o app
139139 ./app
@@ -156,8 +156,8 @@ if (!fs.existsSync(destDir)) {
156156}
157157
158158createApp ( destDir , argv . lang , config ) ;
159+ createEndpoints ( destDir , argv . lang , config ) ;
159160if ( argv . lang === 'js' ) {
160- createEndpoints ( destDir , argv . lang , config ) ;
161161 createPackageJson ( destDir , 'package.json' ) ;
162162}
163163
Original file line number Diff line number Diff line change 11package main
22
33import "fmt"
4+ import "net/http"
5+ import "os"
46
57func main () {
8+ registerRoutes ()
9+
610 fmt .Println ("Listen on 3000" )
11+ if err := http .ListenAndServe (":3000" , nil ); err != nil {
12+ fmt .Fprintf (os .Stderr , "ListenAndServe failed: %v" , err )
13+ os .Exit (1 )
14+ }
715}
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import "net/http"
4+
5+ func registerRoutes() {
6+ <% endpoints .forEach (function (endpoint ) { % >
7+ http .HandleFunc (" <%- endpoint.path %>" , func (w http .ResponseWriter , _ * http .Request ) {
8+ w .Write ([]byte (" TODO" ))
9+ })
10+ < % }) %>
11+ }
You can’t perform that action at this time.
0 commit comments