Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix function comments based on best practices from Effective Go #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ func (s *Server) Match(method string, route string, handler interface{}) {
s.addRoute(route, method, handler)
}

// Add a custom http.Handler. Will have no effect when running as FCGI or SCGI.
// Handle adds a custom http.Handler. Will have no effect when running as FCGI or SCGI.
func (s *Server) Handle(route string, method string, httpHandler http.Handler) {
s.addRoute(route, method, httpHandler)
}

//Adds a handler for websockets. Only for webserver mode. Will have no effect when running as FCGI or SCGI.
// Websocket adds a handler for websockets. Only for webserver mode. Will have no effect when running as FCGI or SCGI.
func (s *Server) Websocket(route string, httpHandler websocket.Handler) {
s.addRoute(route, "GET", httpHandler)
}
Expand Down
4 changes: 2 additions & 2 deletions web.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ func Match(method string, route string, handler interface{}) {
mainServer.addRoute(route, method, handler)
}

// Add a custom http.Handler. Will have no effect when running as FCGI or SCGI.
// Handle adds a custom http.Handler. Will have no effect when running as FCGI or SCGI.
func Handle(route string, method string, httpHandler http.Handler) {
mainServer.Handle(route, method, httpHandler)
}

//Adds a handler for websockets. Only for webserver mode. Will have no effect when running as FCGI or SCGI.
// Websocket adds a handler for websockets. Only for webserver mode. Will have no effect when running as FCGI or SCGI.
func Websocket(route string, httpHandler websocket.Handler) {
mainServer.Websocket(route, httpHandler)
}
Expand Down
12 changes: 6 additions & 6 deletions web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (buf *ioBuffer) Read(p []byte) (n int, err error) {
return buf.input.Read(p)
}

//noop
// Close: noop
func (buf *ioBuffer) Close() error {
buf.closed = true
return nil
Expand Down Expand Up @@ -547,7 +547,7 @@ func TestSlug(t *testing.T) {
}
}

// tests that we don't duplicate headers
// TestDuplicateHeader tests that we don't duplicate headers
func TestDuplicateHeader(t *testing.T) {
resp := testGet("/dupeheader", nil)
if len(resp.headers["Server"]) > 1 {
Expand All @@ -558,7 +558,7 @@ func TestDuplicateHeader(t *testing.T) {
}
}

// test that output contains ASCII color codes by default
// TestColorOutputDefault tests that output contains ASCII color codes by default
func TestColorOutputDefault(t *testing.T) {
s := NewServer()
var logOutput bytes.Buffer
Expand All @@ -577,7 +577,7 @@ func TestColorOutputDefault(t *testing.T) {
}
}

// test that output contains ASCII color codes by default
// TestNoColorOutput tests that output contains ASCII color codes by default
func TestNoColorOutput(t *testing.T) {
s := NewServer()
s.Config.ColorOutput = false
Expand All @@ -597,7 +597,7 @@ func TestNoColorOutput(t *testing.T) {
}
}

// a malformed SCGI request should be discarded and not cause a panic
// TestMaformedScgiRequest: a malformed SCGI request should be discarded and not cause a panic
func TestMaformedScgiRequest(t *testing.T) {
var headerBuf bytes.Buffer

Expand Down Expand Up @@ -625,7 +625,7 @@ type TestHandler struct{}
func (t *TestHandler) ServeHTTP(c http.ResponseWriter, req *http.Request) {
}

// When a custom HTTP handler is used, the Content-Type header should not be set to a default.
// TestCustomHandlerContentType: When a custom HTTP handler is used, the Content-Type header should not be set to a default.
// Go's FileHandler does not replace the Content-Type header if it is already set.
func TestCustomHandlerContentType(t *testing.T) {
s := NewServer()
Expand Down