Skip to content

Commit 42db146

Browse files
committed
feat(network): carry Hostname + StripPrefix on AddRoute for host-scoped routes
1 parent 3367045 commit 42db146

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

network/network.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ type Route struct {
3737
Protocol string `db:"protocol" json:"protocol"`
3838
Weight int `db:"weight" json:"weight"`
3939
StripPrefix bool `db:"strip_prefix" json:"strip_prefix"`
40+
// Hostname, when set, scopes the route to a single host (the
41+
// workspace's API hostname). The OctopusRouter uses it as the
42+
// Gateway API HTTPRoute's `hostnames` entry so per-workspace path
43+
// routes don't collide on the shared *.api wildcard listener.
44+
// Transient: carried from AddRouteRequest to the router at create
45+
// time; not persisted (stores map via their own models).
46+
Hostname string `json:"hostname,omitempty"`
4047
}
4148

4249
// Certificate holds TLS certificate state.

network/service.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ type AddRouteRequest struct {
5858
Port int `json:"port" validate:"required"`
5959
Protocol string `default:"http" json:"protocol"`
6060
Weight int `default:"100" json:"weight"`
61+
StripPrefix bool `json:"strip_prefix,omitempty"`
62+
Hostname string `json:"hostname,omitempty"`
6163
}
6264

6365
// UpdateRouteRequest holds the parameters for modifying a route.

network/service_impl.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ func (s *service) AddRoute(ctx context.Context, req AddRouteRequest) (*Route, er
187187
Port: req.Port,
188188
Protocol: protocol,
189189
Weight: weight,
190+
StripPrefix: req.StripPrefix,
191+
Hostname: req.Hostname,
190192
}
191193

192194
if err := s.store.InsertRoute(ctx, route); err != nil {

0 commit comments

Comments
 (0)