File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 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) {
2525 return server , nil
2626}
2727
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+
2845// StartServer starts an HTTP server created by the CreateServer function.
2946// This is for use with daemon tools.
3047func StartServer (server * http.Server ) error {
You can’t perform that action at this time.
0 commit comments