This commit is contained in:
2025-11-20 13:11:16 +03:00
commit 8b41b82d24
7 changed files with 240 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
package apiserver
import (
"context"
"net"
"net/http"
)
type contextKey struct {
key string
}
var connContextKey = &contextKey{"http-conn"}
func saveConnInContext(ctx context.Context, c net.Conn) context.Context {
return context.WithValue(ctx, connContextKey, c)
}
// Start the server
func Start() error {
srv := newServer()
server := http.Server{
Addr: ":8080",
ConnContext: saveConnInContext,
Handler: srv,
}
return server.ListenAndServe()
}