46 lines
914 B
Go
46 lines
914 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fusen-gateway/gen/go/service"
|
|
"fusen-gateway/proto/goutils"
|
|
"fusen-gateway/server/config"
|
|
"fusen-gateway/server/logic"
|
|
|
|
"net/http"
|
|
|
|
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
|
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/credentials/insecure"
|
|
)
|
|
|
|
func main() {
|
|
|
|
fusen := goutils.NewFusen[config.Config]()
|
|
fusen.StartNacos(nil)
|
|
service.AutoGrpcInit(fusen)
|
|
|
|
ctx := context.Background()
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
defer cancel()
|
|
mux := runtime.NewServeMux(
|
|
runtime.WithForwardResponseOption(logic.ResponseHeaderMatcher),
|
|
runtime.WithMarshalerOption("*", &logic.EmptyMarshaler{}),
|
|
)
|
|
|
|
opts := []grpc.DialOption{
|
|
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
|
}
|
|
|
|
err := logic.AutoRegisterHandler(ctx, mux, opts...)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
err = http.ListenAndServe(":9900", mux)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|