Skip to content

Commit

Permalink
chore: remove previously deprecated WithPort
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanhitt authored and EwenQuim committed Dec 20, 2024
1 parent 2d3fbb8 commit 17ded45
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 40 deletions.
16 changes: 0 additions & 16 deletions documentation/docs/guides/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,6 @@ func main() {
}
```

### Port (Deprecated)

**Deprecated** in favor of `WithAddr` shown above.

You can change the port of the server with the `WithPort` option.

```go
import "github.com/go-fuego/fuego"

func main() {
s := fuego.NewServer(
fuego.WithPort(8080),
)
}
```

### CORS

CORS middleware is not registered as a usual middleware,
Expand Down
10 changes: 0 additions & 10 deletions server.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package fuego

import (
"fmt"
"html/template"
"io"
"io/fs"
Expand Down Expand Up @@ -304,15 +303,6 @@ func WithDisallowUnknownFields(b bool) func(*Server) {
return func(c *Server) { c.DisallowUnknownFields = b }
}

// WithPort sets the port of the server. For example, 8080.
// If not specified, the default port is 9999.
// If you want to use a different address, use [WithAddr] instead.
//
// Deprecated: Please use [WithAddr]
func WithPort(port int) func(*Server) {
return func(s *Server) { s.Server.Addr = fmt.Sprintf("localhost:%d", port) }
}

// WithAddr optionally specifies the TCP address for the server to listen on, in the form "host:port".
// If not specified addr ':9999' will be used.
func WithAddr(addr string) func(*Server) {
Expand Down
14 changes: 0 additions & 14 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,6 @@ func TestWithAddr(t *testing.T) {
}
}

func TestWithPort(t *testing.T) {
t.Run("with custom port, that port is used", func(t *testing.T) {
s := NewServer(
WithPort(8488),
)
require.Equal(t, "localhost:8488", s.Server.Addr)
})

t.Run("no port provided, default is used (9999)", func(t *testing.T) {
s := NewServer()
require.Equal(t, "localhost:9999", s.Server.Addr)
})
}

func TestWithoutStartupMessages(t *testing.T) {
s := NewServer(
WithoutStartupMessages(),
Expand Down

0 comments on commit 17ded45

Please sign in to comment.