File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,23 @@ func CreateServer() (*http.Server, error) {
25
25
return server , nil
26
26
}
27
27
28
+ // CreateServerWithMux creates a new HTTP server with TLS configured for GPTScript.
29
+ // This function should be used when creating a new server for a daemon tool with a custom ServeMux.
30
+ // The server should then be started with the StartServer function.
31
+ func CreateServerWithMux (mux * http.ServeMux ) (* http.Server , error ) {
32
+ tlsConfig , err := getTLSConfig ()
33
+ if err != nil {
34
+ return nil , fmt .Errorf ("failed to get TLS config: %v" , err )
35
+ }
36
+
37
+ server := & http.Server {
38
+ Addr : fmt .Sprintf ("127.0.0.1:%s" , os .Getenv ("PORT" )),
39
+ TLSConfig : tlsConfig ,
40
+ Handler : mux ,
41
+ }
42
+ return server , nil
43
+ }
44
+
28
45
// StartServer starts an HTTP server created by the CreateServer function.
29
46
// This is for use with daemon tools.
30
47
func StartServer (server * http.Server ) error {
You can’t perform that action at this time.
0 commit comments