<commit_before>// Package neptulon is a RPC framework with middleware support.
package neptulon

import (
	"log"
	"net/http"
	"net/url"

	"github.com/neptulon/cmap"

	"golang.org/x/net/websocket"
)

// Server is a Neptulon server.
type Server struct {
	addr       string
	conns      *cmap.CMap // conn ID -> Conn
	middleware []func(ctx *ReqCtx) error
}

// NewServer creates a new Neptulon server.
func NewServer(addr string) *Server {
	return &Server{
		addr:  addr,
		conns: cmap.New(),
	}
}

// Middleware registers middleware to handle incoming request messages.
func (s *Server) Middleware(middleware ...func(ctx *ReqCtx) error) {
	s.middleware = append(s.middleware, middleware...)
}

// Start the Neptulon server. This function blocks until server is closed.
func (s *Server) Start() error {
	http.Handle("/", websocket.Server{
		Handler: s.connHandler,
		Handshake: func(config *websocket.Config, req *http.Request) error {
			config.Origin, _ = url.Parse(req.RemoteAddr)
			return nil
		},
	})
	log.Println("Neptulon server started at address:", s.addr)
	return http.ListenAndServe(s.addr, nil)
}
<commit_msg>add comment on origin<commit_after>// Package neptulon is a RPC framework with middleware support.
package neptulon

import (
	"log"
	"net/http"
	"net/url"

	"github.com/neptulon/cmap"

	"golang.org/x/net/websocket"
)

// Server is a Neptulon server.
type Server struct {
	addr       string
	conns      *cmap.CMap // conn ID -> Conn
	middleware []func(ctx *ReqCtx) error
}

// NewServer creates a new Neptulon server.
func NewServer(addr string) *Server {
	return &Server{
		addr:  addr,
		conns: cmap.New(),
	}
}

// Middleware registers middleware to handle incoming request messages.
func (s *Server) Middleware(middleware ...func(ctx *ReqCtx) error) {
	s.middleware = append(s.middleware, middleware...)
}

// Start the Neptulon server. This function blocks until server is closed.
func (s *Server) Start() error {
	http.Handle("/", websocket.Server{
		Handler: s.connHandler,
		Handshake: func(config *websocket.Config, req *http.Request) error {
			config.Origin, _ = url.Parse(req.RemoteAddr) // we're interested in remote address and not origin header text
			return nil
		},
	})
	log.Println("Neptulon server started at address:", s.addr)
	return http.ListenAndServe(s.addr, nil)
}

{'fraction_non_alphanumeric': 0.12343005630142918, 'fraction_numerical': 0.0, 'mean_word_length': 3.7628865979381443, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2785134', 'n_tokens_mistral': 819, 'n_tokens_neox': 789, 'n_words': 233}