File tree 5 files changed +52
-2
lines changed
5 files changed +52
-2
lines changed Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import "fmt"
4
+ import "net/http"
5
+ import "os"
4
6
5
7
func main () {
8
+ registerRoutes ()
9
+
6
10
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
+ }
7
15
}
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
133
133
afteward to run` ) ;
134
134
} else if ( argv . lang === 'go' ) {
135
135
console . info ( `Use
136
- go run app .go
136
+ go run * .go
137
137
or
138
138
go build -o app
139
139
./app
@@ -156,8 +156,8 @@ if (!fs.existsSync(destDir)) {
156
156
}
157
157
158
158
createApp ( destDir , argv . lang , config ) ;
159
+ createEndpoints ( destDir , argv . lang , config ) ;
159
160
if ( argv . lang === 'js' ) {
160
- createEndpoints ( destDir , argv . lang , config ) ;
161
161
createPackageJson ( destDir , 'package.json' ) ;
162
162
}
163
163
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import "fmt"
4
+ import "net/http"
5
+ import "os"
4
6
5
7
func main () {
8
+ registerRoutes ()
9
+
6
10
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
+ }
7
15
}
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