Skip to content

Commit

Permalink
Cleanup of HTTP routing
Browse files Browse the repository at this point in the history
No need to use both gorilla's mux and http's ServeMux.
  • Loading branch information
martinhpedersen committed Oct 13, 2023
1 parent b62dbc7 commit 49bb71f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,18 @@ func ListenAndServe(ctx context.Context, addr string) error {
r.HandleFunc("/api/current_gps_position", positionHandler).Methods("GET")
r.HandleFunc("/api/qsy", qsyHandler).Methods("POST")
r.HandleFunc("/api/rmslist", rmslistHandler).Methods("GET")

r.PathPrefix("/dist/").Handler(distHandler())
r.HandleFunc("/ws", wsHandler)
r.HandleFunc("/ui", uiHandler()).Methods("GET")
r.HandleFunc("/", rootHandler).Methods("GET")

http.Handle("/", r)
http.Handle("/dist/", distHandler())

websocketHub = NewWSHub()

srv := http.Server{Addr: addr}
srv := http.Server{
Addr: addr,
Handler: r,
}
errs := make(chan error, 1)
go func() {
errs <- srv.ListenAndServe()
Expand Down

0 comments on commit 49bb71f

Please sign in to comment.