Skip to content

Commit

Permalink
add ui
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed Mar 23, 2024
1 parent 7349b1e commit 8395176
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "stub/ui"]
path = stub/ui
url = [email protected]:bavix/gripmock-ui.git
10 changes: 9 additions & 1 deletion stub/stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package stub

import (
"context"
"embed"
"errors"
"github.com/bavix/gripmock/internal/pkg/grpcreflector"
"io/fs"
"net"
"net/http"
"time"
Expand All @@ -16,6 +17,7 @@ import (
"github.com/bavix/gripmock/internal/app"
"github.com/bavix/gripmock/internal/domain/rest"
"github.com/bavix/gripmock/internal/pkg/features"
"github.com/bavix/gripmock/internal/pkg/grpcreflector"
"github.com/bavix/gripmock/internal/pkg/muxmiddleware"
)

Expand All @@ -25,16 +27,22 @@ type Options struct {
StubPath string
}

//go:embed ui/dist

Check failure on line 30 in stub/stub.go

View workflow job for this annotation

GitHub Actions / test (1.22)

pattern ui/dist: no matching files found
var staticFiles embed.FS

func RunRestServer(ctx context.Context, ch chan struct{}, opt Options, reflector *grpcreflector.GReflector) {
const timeout = time.Millisecond * 25

addr := net.JoinHostPort(opt.BindAddr, opt.Port)

apiServer, _ := app.NewRestServer(opt.StubPath, reflector)

htmlContent, _ := fs.Sub(staticFiles, "ui/dist")

router := mux.NewRouter()
router.Use(muxmiddleware.RequestLogger)
router.Use(otelmux.Middleware("gripmock-manager"))
router.Handle("/", http.FileServer(http.FS(htmlContent)))
rest.HandlerFromMuxWithBaseURL(apiServer, router, "/api")

srv := &http.Server{
Expand Down
1 change: 1 addition & 0 deletions stub/ui
Submodule ui added at 3b5893

0 comments on commit 8395176

Please sign in to comment.