[PR #78] [MERGED] Implement server helper API for lookup/listen/location management #76

Closed
opened 2026-02-28 01:20:48 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/tufanbarisyildirim/gonginx/pull/78
Author: @tufanbarisyildirim
Created: 2/20/2026
Status: Merged
Merged: 2/20/2026
Merged by: @tufanbarisyildirim

Base: masterHead: fix/issue-47-server-helper-api


📝 Commits (1)

  • 75ffbc2 Add server helper APIs for name, listen, and locations

📊 Changes

5 files changed (+372 additions, -0 deletions)

View changed files

📝 GUIDE.md (+45 -0)
📝 config/http.go (+17 -0)
config/http_test.go (+46 -0)
📝 config/server.go (+139 -0)
📝 config/server_test.go (+125 -0)

📄 Description

Final API Decision (owner-level)

This issue requested a richer server API. To keep it practical and backward-compatible, this PR implements a method-based first step instead of introducing a new Listen model right now.

Implemented:

  • (*config.HTTP).GetServerByServerName(serverName string) *Server
  • (*config.Server).GetLocations() []*Location (direct child locations only)
  • (*config.Server).GetListenPorts() []int (numeric TCP ports only)
  • (*config.Server).SetListenPort(index int, port int) error

Behavior decisions:

  • GetServerByServerName returns the first matching server (or nil)
  • GetListenPorts ignores non-port listen endpoints (for example unix:/...)
  • SetListenPort preserves listen endpoint form when possible (80, 127.0.0.1:8080, [::]:443)

Tests

  • Added config/http_test.go
  • Extended config/server_test.go with listen/location helper coverage
  • Ran go test ./config
  • Ran make test

Closes #47


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/tufanbarisyildirim/gonginx/pull/78 **Author:** [@tufanbarisyildirim](https://github.com/tufanbarisyildirim) **Created:** 2/20/2026 **Status:** ✅ Merged **Merged:** 2/20/2026 **Merged by:** [@tufanbarisyildirim](https://github.com/tufanbarisyildirim) **Base:** `master` ← **Head:** `fix/issue-47-server-helper-api` --- ### 📝 Commits (1) - [`75ffbc2`](https://github.com/tufanbarisyildirim/gonginx/commit/75ffbc2107a3c55990ebbb8eef3425db973abe24) Add server helper APIs for name, listen, and locations ### 📊 Changes **5 files changed** (+372 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `GUIDE.md` (+45 -0) 📝 `config/http.go` (+17 -0) ➕ `config/http_test.go` (+46 -0) 📝 `config/server.go` (+139 -0) 📝 `config/server_test.go` (+125 -0) </details> ### 📄 Description ## Final API Decision (owner-level) This issue requested a richer server API. To keep it practical and backward-compatible, this PR implements a **method-based first step** instead of introducing a new `Listen` model right now. Implemented: - `(*config.HTTP).GetServerByServerName(serverName string) *Server` - `(*config.Server).GetLocations() []*Location` (direct child locations only) - `(*config.Server).GetListenPorts() []int` (numeric TCP ports only) - `(*config.Server).SetListenPort(index int, port int) error` Behavior decisions: - `GetServerByServerName` returns the **first matching** server (or `nil`) - `GetListenPorts` ignores non-port listen endpoints (for example `unix:/...`) - `SetListenPort` preserves listen endpoint form when possible (`80`, `127.0.0.1:8080`, `[::]:443`) ## Tests - Added `config/http_test.go` - Extended `config/server_test.go` with listen/location helper coverage - Ran `go test ./config` - Ran `make test` Closes #47 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 01:20:48 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/gonginx#76
No description provided.