44package server
55
66import (
7+ "cmp"
78 "context"
89 "errors"
910 "fmt"
@@ -222,6 +223,8 @@ func (s *Server) createApp(ctx context.Context, appEntry *types.AppEntry, approv
222223 }
223224
224225 ret := & types.AppCreateResponse {
226+ HttpUrl : s .getAppHttpUrl (appEntry ),
227+ HttpsUrl : s .getAppHttpsUrl (appEntry ),
225228 DryRun : dryRun ,
226229 ApproveResults : results ,
227230 }
@@ -238,6 +241,24 @@ func (s *Server) createApp(ctx context.Context, appEntry *types.AppEntry, approv
238241 return ret , nil
239242}
240243
244+ // getAppHttpUrl returns the HTTP URL for accessing the app
245+ func (s * Server ) getAppHttpUrl (appEntry * types.AppEntry ) string {
246+ if s .config .Http .Port <= 0 {
247+ return ""
248+ }
249+ domain := cmp .Or (appEntry .Domain , "localhost" )
250+ return fmt .Sprintf ("%s://%s:%d%s" , "http" , domain , s .config .Http .Port , appEntry .Path )
251+ }
252+
253+ // getAppHttpsUrl returns the HTTPS URL for accessing the app
254+ func (s * Server ) getAppHttpsUrl (appEntry * types.AppEntry ) string {
255+ if s .config .Https .Port <= 0 {
256+ return ""
257+ }
258+ domain := cmp .Or (appEntry .Domain , "localhost" )
259+ return fmt .Sprintf ("%s://%s:%d%s" , "https" , domain , s .config .Https .Port , appEntry .Path )
260+ }
261+
241262func (s * Server ) setupApp (appEntry * types.AppEntry , tx types.Transaction ) (* app.App , error ) {
242263 subLogger := s .With ().Str ("id" , string (appEntry .Id )).Str ("path" , appEntry .Path ).Logger ()
243264 appLogger := types.Logger {Logger : & subLogger }
@@ -907,6 +928,8 @@ func (s *Server) PreviewApp(ctx context.Context, mainAppPath, commitId string, a
907928
908929 ret := & types.AppPreviewResponse {
909930 DryRun : dryRun ,
931+ HttpUrl : s .getAppHttpUrl (& previewAppEntry ),
932+ HttpsUrl : s .getAppHttpsUrl (& previewAppEntry ),
910933 ApproveResult : * auditResult ,
911934 Success : true ,
912935 }
0 commit comments