From 04a7f643fe71329116daf512fe6432fb7f9ad2f2 Mon Sep 17 00:00:00 2001 From: David Subiros Date: Mon, 11 May 2020 09:05:12 +0100 Subject: [PATCH] fixed READMEs, removed unused error types and removed duplicated function in server --- README.md | 2 +- handlers/README.md | 2 +- http/errors.go | 28 ---------------------------- http/server.go | 5 ----- 4 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 http/errors.go diff --git a/README.md b/README.md index 9ebac61..16651f9 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ func main() { ### Server -The Serer extends the default golang HTTP Server by adding a requestID and logger middleware. By default it handles the OSSignals, and it has a default shutdown timeout of 10 seconds. +The Server extends the default golang HTTP Server by adding a requestID and logger middleware. By default it handles the OSSignals, and it has a default shutdown timeout of 10 seconds. This Server is intended to be used by all ONS digital publishing services that require to serve HTTP. The following example shows how to use the Server: diff --git a/handlers/README.md b/handlers/README.md index 712d431..00f3d6e 100644 --- a/handlers/README.md +++ b/handlers/README.md @@ -6,7 +6,7 @@ The mapping is done using enumeration of possible header and cookie keys, and th ## Usage -- Read a header from a request and add its value to the output request context: +- Read a header from a request and add its value to the underlying request context: ```go // Access token diff --git a/http/errors.go b/http/errors.go deleted file mode 100644 index 2d8ab01..0000000 --- a/http/errors.go +++ /dev/null @@ -1,28 +0,0 @@ -package http - -// ONSError encapsulates an error with additional parameters -type ONSError struct { - Parameters map[string]interface{} - RootError error -} - -// NewONSError creates a new ONS error -func NewONSError(e error, description string) *ONSError { - err := &ONSError{RootError: e} - err.AddParameter("ErrorDescription", description) - return err -} - -// Error returns the ONSError RootError message -func (e ONSError) Error() string { - return e.RootError.Error() -} - -// AddParameter method creates or overwrites parameters attatched to an ONSError -func (e *ONSError) AddParameter(name string, value interface{}) *ONSError { - if e.Parameters == nil { - e.Parameters = make(map[string]interface{}, 0) - } - e.Parameters[name] = value - return e -} diff --git a/http/server.go b/http/server.go index 951eb71..610d6e4 100644 --- a/http/server.go +++ b/http/server.go @@ -103,11 +103,6 @@ func (s *Server) Shutdown(ctx context.Context) error { return s.Server.Shutdown(ctx) } -// Close is simply a wrapper around Shutdown that enables Server to be treated as a Closable -func (s *Server) Close(ctx context.Context) error { - return s.Shutdown(ctx) -} - func (s *Server) listenAndServe() error { s.prep()