package main import ( "log" "net/http" "git.xdrm.io/go/tiny-url-ex/service/auth" "git.xdrm.io/go/tiny-url-ex/service/shortener" "git.xdrm.io/go/aicra" "git.xdrm.io/go/aicra/typecheck/builtin" ) func main() { listenTo := ":4242" // 1. build server log.Printf("[server] building") server, err := aicra.New("api.json") if err != nil { log.Fatalf("/!\\ cannot init server: %v\n", err) } // 2. add type checkers server.Checkers.Add(builtin.NewAny()) server.Checkers.Add(builtin.NewString()) server.Checkers.Add(builtin.NewFloat64()) // 3. init services authService, err := auth.New() if err != nil { log.Fatalf("cannot create auth service: %v", err) } shortenerService, err := shortener.New(authService) if err != nil { log.Fatalf("cannot create auth service: %v", err) } // 4. wire services shortenerService.Wire(server) authService.Wire(server) // 5. listen and serve log.Printf("[server] listening %s\n\n", listenTo) log.Fatal(http.ListenAndServe(listenTo, server.HTTP())) }