-
Notifications
You must be signed in to change notification settings - Fork 13
/
main.go
37 lines (31 loc) · 985 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
33
34
35
36
37
package main
import (
"log"
"net/http"
"github.com/Stratoscale/swagger/example/auth"
"github.com/Stratoscale/swagger/example/internal/pet"
"github.com/Stratoscale/swagger/example/internal/store"
"github.com/Stratoscale/swagger/example/restapi"
)
func main() {
// Initiate business logic implementers.
// This is the main function, so here the implementers' dependencies can be
// injected, such as database, parameters from environment variables, or different
// clients for different APIs.
p := pet.New()
s := store.Store{}
// Initiate the http handler, with the objects that are implementing the business logic.
h, err := restapi.Handler(restapi.Config{
PetAPI: p,
StoreAPI: &s,
AuthToken: auth.Token,
Authorizer: auth.Request,
Logger: log.Printf,
})
if err != nil {
log.Fatal(err)
}
log.Println("Starting to serve, access server on http://localhost:8080")
// Run the standard http server
log.Fatal(http.ListenAndServe(":8080", h))
}