[GH-ISSUE #47] [feature request]enhanced server object capabilities for easier access and modification of nginx configuration #20

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

Originally created by @mofantor on GitHub (Apr 22, 2024).
Original GitHub issue: https://github.com/tufanbarisyildirim/gonginx/issues/47

propose to enhance the server object by adding new attributes and methods that will simplify the access and modification of its listening configuration, location details, and other pertinent settings. The following are potential enhancements and features that could be incorporated:

// get server by servername
server := conf.GetBlock(*.config.HTTP).GetServerByServerName("example.com")

// get all listening ports for the server
listenPorts := server.GetListenPorts()

// change the first listen port configuration to 8080
server.Listens[0].SetListenPort(8080)

// retrieve all location configurations for the server
locations := server.GetLocations()

Please consider implementing these functionalities to streamline working with complex server configurations and encourage more robust and dynamic management of Nginx setup through this library.

Let's discuss the feasibility and potential implementation details for these enhancements under this issue thread.

Originally created by @mofantor on GitHub (Apr 22, 2024). Original GitHub issue: https://github.com/tufanbarisyildirim/gonginx/issues/47 propose to enhance the server object by adding new attributes and methods that will simplify the access and modification of its listening configuration, location details, and other pertinent settings. The following are potential enhancements and features that could be incorporated: ```go // get server by servername server := conf.GetBlock(*.config.HTTP).GetServerByServerName("example.com") // get all listening ports for the server listenPorts := server.GetListenPorts() // change the first listen port configuration to 8080 server.Listens[0].SetListenPort(8080) // retrieve all location configurations for the server locations := server.GetLocations() ``` Please consider implementing these functionalities to streamline working with complex server configurations and encourage more robust and dynamic management of Nginx setup through this library. Let's discuss the feasibility and potential implementation details for these enhancements under this issue thread.
kerem 2026-02-28 01:20:32 +03:00
Author
Owner

@tufanbarisyildirim commented on GitHub (Jun 8, 2024):

sounds good, would you like to take this?

<!-- gh-comment-id:2156180691 --> @tufanbarisyildirim commented on GitHub (Jun 8, 2024): sounds good, would you like to take this?
Author
Owner

@mofantor commented on GitHub (Jun 11, 2024):

I would like to develop these features. Some of the features have already been implemented in the project I am working on. After the completion of the subsequent work, I will submit a Pull Request.

<!-- gh-comment-id:2159975994 --> @mofantor commented on GitHub (Jun 11, 2024): I would like to develop these features. Some of the features have already been implemented in the project I am working on. After the completion of the subsequent work, I will submit a Pull Request.
Author
Owner

@tufanbarisyildirim commented on GitHub (Jun 11, 2024):

awesome! looking forward to it!

<!-- gh-comment-id:2160013259 --> @tufanbarisyildirim commented on GitHub (Jun 11, 2024): awesome! looking forward to it!
Author
Owner

@tufanbarisyildirim commented on GitHub (Feb 20, 2026):

Thanks for the feature proposal. I’m interested in implementing this, but I need to confirm API shape/scope before coding.

  1. GetServerByServerName("example.com"): should this return the first matching server or all matching servers?
  2. For listen parsing, should GetListenPorts() include only numeric TCP ports, or also unix sockets / host:port forms / flags (e.g. listen 127.0.0.1:8080 ssl)?
  3. Do you want a new typed Listen model (like your server.Listens[0].SetListenPort(8080) example), or would method-based APIs on Server be acceptable (GetListenPorts, SetListenPort helpers)?
  4. For locations, should GetLocations() return only direct child location blocks, or include nested locations recursively?

Once you confirm these, I can open a focused PR.

<!-- gh-comment-id:3932175797 --> @tufanbarisyildirim commented on GitHub (Feb 20, 2026): Thanks for the feature proposal. I’m interested in implementing this, but I need to confirm API shape/scope before coding. 1. `GetServerByServerName("example.com")`: should this return the first matching server or all matching servers? 2. For listen parsing, should `GetListenPorts()` include only numeric TCP ports, or also unix sockets / host:port forms / flags (e.g. `listen 127.0.0.1:8080 ssl`)? 3. Do you want a new typed `Listen` model (like your `server.Listens[0].SetListenPort(8080)` example), or would method-based APIs on `Server` be acceptable (`GetListenPorts`, `SetListenPort` helpers)? 4. For locations, should `GetLocations()` return only direct child `location` blocks, or include nested locations recursively? Once you confirm these, I can open a focused PR.
Author
Owner

@tufanbarisyildirim commented on GitHub (Feb 20, 2026):

Quick follow-up to unblock implementation: if this sounds good, I can proceed with these defaults in a PR:

  1. GetServerByServerName(name string) *Server: return first match (nil if none)
  2. GetListenPorts() []int: return only numeric TCP ports (ignore unix sockets/non-numeric forms)
  3. No new Listen struct initially; add method-based helpers on Server
  4. GetLocations() []*Location: return direct child location blocks only

Please confirm or adjust these 4 points.

<!-- gh-comment-id:3932177755 --> @tufanbarisyildirim commented on GitHub (Feb 20, 2026): Quick follow-up to unblock implementation: if this sounds good, I can proceed with these defaults in a PR: 1. `GetServerByServerName(name string) *Server`: return first match (nil if none) 2. `GetListenPorts() []int`: return only numeric TCP ports (ignore unix sockets/non-numeric forms) 3. No new `Listen` struct initially; add method-based helpers on `Server` 4. `GetLocations() []*Location`: return direct child `location` blocks only Please confirm or adjust these 4 points.
Author
Owner

@tufanbarisyildirim commented on GitHub (Feb 20, 2026):

Can I proceed with the 4 defaults in my previous comment and open a PR? A simple "yes" (or 👍) is enough, and I’ll implement exactly that scope.

<!-- gh-comment-id:3932179310 --> @tufanbarisyildirim commented on GitHub (Feb 20, 2026): Can I proceed with the 4 defaults in my previous comment and open a PR? A simple "yes" (or 👍) is enough, and I’ll implement exactly that scope.
Author
Owner

@tufanbarisyildirim commented on GitHub (Feb 20, 2026):

Checking in on ownership to unblock this: are you still planning to submit the PR you mentioned? If not, I can implement this with the default API scope described above and open a PR.

<!-- gh-comment-id:3932181541 --> @tufanbarisyildirim commented on GitHub (Feb 20, 2026): Checking in on ownership to unblock this: are you still planning to submit the PR you mentioned? If not, I can implement this with the default API scope described above and open a PR.
Author
Owner

@tufanbarisyildirim commented on GitHub (Feb 20, 2026):

Final scope confirmation question to unblock this:

If there is no objection, can I proceed with the default minimal API set below?

  • HTTP.GetServerByServerName(name string) *Server (first match, nil if none)
  • Server.GetListenPorts() []int (numeric TCP ports only)
  • Server.GetLocations() []*Location (direct child locations only)

If you want different behavior, please list exact method signatures and rules and I’ll follow that instead.

<!-- gh-comment-id:3932183116 --> @tufanbarisyildirim commented on GitHub (Feb 20, 2026): Final scope confirmation question to unblock this: If there is no objection, can I proceed with the default minimal API set below? - `HTTP.GetServerByServerName(name string) *Server` (first match, nil if none) - `Server.GetListenPorts() []int` (numeric TCP ports only) - `Server.GetLocations() []*Location` (direct child locations only) If you want different behavior, please list exact method signatures and rules and I’ll follow that instead.
Author
Owner

@tufanbarisyildirim commented on GitHub (Feb 20, 2026):

Owner decision and implementation is now in #78.

Chosen scope:

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

This keeps API additions small and stable while directly covering the requested workflows (lookup, inspect, and mutate server listen/location configuration).

<!-- gh-comment-id:3932323041 --> @tufanbarisyildirim commented on GitHub (Feb 20, 2026): Owner decision and implementation is now in #78. Chosen scope: - `HTTP.GetServerByServerName(serverName string) *Server` (first match) - `Server.GetLocations() []*Location` (direct child locations) - `Server.GetListenPorts() []int` (numeric ports) - `Server.SetListenPort(index int, port int) error` This keeps API additions small and stable while directly covering the requested workflows (lookup, inspect, and mutate server listen/location configuration).
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#20
No description provided.