v2.10.1 43db1bb

handler.go RawHistoryFolder

1// Package proxy implements the HTTP adapter for the reverse proxy.
2package proxy
3
4import (
5	"context"
6	"net/http"
7	"strconv"
8	"time"
9
10	"github.com/bnema/zerowrap"
11
12	"github.com/bnema/gordon/internal/boundaries/in"
13)
14
15// Handler wraps the proxy service for HTTP.
16// The actual proxying logic is in the usecase layer (ProxyService implements http.Handler).
17type Handler struct {
18	proxySvc in.ProxyService
19	log      zerowrap.Logger
20	port     int
21}
22
23// NewHandler creates a new proxy HTTP handler.
24func NewHandler(proxySvc in.ProxyService, port int, log zerowrap.Logger) *Handler {
25	return &Handler{
26		proxySvc: proxySvc,
27		port:     port,
28		log:      log,
29	}
30}
31
32// ServeHTTP implements http.Handler by delegating to the proxy service.
33func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
34	h.proxySvc.ServeHTTP(w, r)
35}
36
37// Start starts the proxy HTTP server.
38func (h *Handler) Start(ctx context.Context, handler http.Handler) error {
39	addr := ":" + strconv.Itoa(h.port)
40
41	server := &http.Server{
42		Addr:              addr,
43		Handler:           handler,
44		ReadHeaderTimeout: 10 * time.Second,
45		ReadTimeout:       5 * time.Minute,   // Timeout for reading entire request
46		WriteTimeout:      5 * time.Minute,   // Timeout for writing response
47		IdleTimeout:       120 * time.Second, // Timeout for idle keep-alive connections
48		MaxHeaderBytes:    1 << 20,           // 1MB max header size
49	}
50
51	h.log.Info().
52		Str(zerowrap.FieldLayer, "adapter").
53		Str(zerowrap.FieldAdapter, "http").
54		Str("address", addr).
55		Msg("proxy server starting")
56
57	// Start server in a goroutine
58	errChan := make(chan error, 1)
59	go func() {
60		if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
61			errChan <- err
62		}
63	}()
64
65	// Wait for context cancellation or server error
66	select {
67	case err := <-errChan:
68		return err
69	case <-ctx.Done():
70		h.log.Info().
71			Str(zerowrap.FieldLayer, "adapter").
72			Str(zerowrap.FieldAdapter, "http").
73			Msg("proxy server shutting down")
74		return server.Shutdown(context.Background())
75	}
76}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close