diff --git a/.gitignore b/.gitignore index 710a5fb..daf3825 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,11 @@ _obj _test src +# IDE +.project +.settings +.idea + # Architecture specific extensions/prefixes *.[568vq] [568vq].out diff --git a/.testpackages b/.testpackages index 10b2575..7176d9c 100644 --- a/.testpackages +++ b/.testpackages @@ -1,18 +1,18 @@ -gopkg.in/webnice/web.v1 -gopkg.in/webnice/web.v1/ambry -gopkg.in/webnice/web.v1/context -gopkg.in/webnice/web.v1/context/errors -gopkg.in/webnice/web.v1/context/handlers -gopkg.in/webnice/web.v1/context/route -gopkg.in/webnice/web.v1/header -gopkg.in/webnice/web.v1/method -gopkg.in/webnice/web.v1/mime -gopkg.in/webnice/web.v1/param -gopkg.in/webnice/web.v1/route -gopkg.in/webnice/web.v1/status -gopkg.in/webnice/web.v1/proxyp -gopkg.in/webnice/web.v1/proxyp/tlvparse -gopkg.in/webnice/web.v1/middleware/recovery -gopkg.in/webnice/web.v1/middleware/pprof -gopkg.in/webnice/web.v1/middleware/nocache -gopkg.in/webnice/web.v1/middleware/contentTypeDefault +github.com/webnice/web +github.com/webnice/web/ambry +github.com/webnice/web/context +github.com/webnice/web/context/errors +github.com/webnice/web/context/handlers +github.com/webnice/web/context/route +github.com/webnice/web/header +github.com/webnice/web/method +github.com/webnice/web/mime +github.com/webnice/web/param +github.com/webnice/web/route +github.com/webnice/web/status +github.com/webnice/web/proxyp +github.com/webnice/web/proxyp/tlvparse +github.com/webnice/web/middleware/recovery +github.com/webnice/web/middleware/pprof +github.com/webnice/web/middleware/nocache +github.com/webnice/web/middleware/contentTypeDefault diff --git a/.travis.yml b/.travis.yml index 67583a9..b630e99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,7 @@ language: go install: - go get github.com/mattn/goveralls - - go get gopkg.in/webnice/debug.v1 - - go get gopkg.in/webnice/log.v2 + - go get github.com/webnice/debug script: - make test diff --git a/Makefile b/Makefile index 7b3202d..02f1fe7 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ GO111MODULE ?= $(GO111MODULE:on) default: help link: - @mkdir -p src/gopkg.in/webnice; cd src/gopkg.in/webnice && ln -s ../../.. web.v1 2>/dev/null; true + @mkdir -p src/github.com/webnice; cd src/github.com/webnice && ln -s ../../.. web 2>/dev/null; true .PHONY: link ## Code generation (run only during development) @@ -30,7 +30,7 @@ test: link @echo "mode: set" > coverage.log @for PACKET in $(TESTPACKETS); do \ touch coverage-tmp.log; \ - GOPATH=${GOPATH} go test -v -covermode=count -coverprofile=coverage-tmp.log $$PACKET; \ + GO111MODULE="off" go test -v -covermode=count -coverprofile=coverage-tmp.log $$PACKET; \ if [ "$$?" -ne "0" ]; then exit $$?; fi; \ tail -n +2 coverage-tmp.log | sort -r | awk '{if($$1 != last) {print $$0;last=$$1}}' >> coverage.log; \ rm -f coverage-tmp.log; true; \ @@ -39,7 +39,7 @@ test: link ## Displaying in the browser coverage of tested code, on the html report (run only during development) cover: test - @GOPATH=${GOPATH} go tool cover -html=$(DIR)/coverage.log + @GOPATH=${GOPATH} GO111MODULE="off" go tool cover -html=$(DIR)/coverage.log .PHONY: cover ## Performance testing diff --git a/README.md b/README.md index e5ce22d..7d5b0d5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # web -[![GoDoc](https://godoc.org/gopkg.in/webnice/web.v1?status.png)](http://godoc.org/gopkg.in/webnice/web.v1) +[![GoDoc](https://godoc.org/github.com/webnice/web?status.png)](http://godoc.org/github.com/webnice/web) [![Go Report Card](https://goreportcard.com/badge/github.com/webnice/web)](https://goreportcard.com/report/github.com/webnice/web) [![Coverage Status](https://coveralls.io/repos/github/webnice/web/badge.svg?branch=v1)](https://coveralls.io/github/webnice/web?branch=v1) [![Build Status](https://travis-ci.org/webnice/web.svg?branch=v1)](https://travis-ci.org/webnice/web) @@ -20,5 +20,5 @@ But at the same time framework adds to your application a full-functions routing #### Install ```bash -go get gopkg.in/webnice/web.v1 +go get github.com/webnice/web ``` diff --git a/ambry/ambry.go b/ambry/ambry.go index 672c7ea..27c0623 100644 --- a/ambry/ambry.go +++ b/ambry/ambry.go @@ -1,8 +1,5 @@ package ambry -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" - // New is a constructor func New() Interface { var itm = new(impl) diff --git a/ambry/ambry_bench_test.go b/ambry/ambry_bench_test.go index 50c79a1..6b8140a 100644 --- a/ambry/ambry_bench_test.go +++ b/ambry/ambry_bench_test.go @@ -1,13 +1,11 @@ package ambry -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import ( - "testing" -) +import "testing" -const KEY = "foo" -const VAL = "bar" +const ( + KEY = "foo" + VAL = "bar" +) var res interface{} diff --git a/ambry/ambry_test.go b/ambry/ambry_test.go index 83eee7f..5ae10b3 100644 --- a/ambry/ambry_test.go +++ b/ambry/ambry_test.go @@ -1,10 +1,6 @@ package ambry -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import ( - "testing" -) +import "testing" var ( k = `A69F2F4D-0B8F-43D3-8E1B-1EA90766FEB5` diff --git a/ambry/types.go b/ambry/types.go index e44cfa4..81a8fc2 100644 --- a/ambry/types.go +++ b/ambry/types.go @@ -1,7 +1,5 @@ package ambry -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import "sync" // Interface is an interface of package diff --git a/circle.yml b/circle.yml index 69e72c4..2aa39e7 100644 --- a/circle.yml +++ b/circle.yml @@ -1,7 +1,7 @@ dependencies: override: - - mkdir -p src/gopkg.in/webnice - - cd src/gopkg.in/webnice && ln -s ../../.. web.v1 2>/dev/null + - mkdir -p src/github.com/webnice + - cd src/github.com/webnice && ln -s ../../.. web 2>/dev/null test: override: diff --git a/constants.go b/constants.go index 8125df3..d8a1635 100644 --- a/constants.go +++ b/constants.go @@ -1,11 +1,5 @@ package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import ( - "time" -) +import "time" -const ( - shutdownTimeout time.Duration = time.Minute / 2 -) +const shutdownTimeout time.Duration = time.Minute / 2 diff --git a/context/context.go b/context/context.go index a461899..e8b0588 100644 --- a/context/context.go +++ b/context/context.go @@ -1,14 +1,12 @@ package context -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( stdContext "context" "net/http" - "gopkg.in/webnice/web.v1/context/errors" - "gopkg.in/webnice/web.v1/context/handlers" - "gopkg.in/webnice/web.v1/context/route" + "github.com/webnice/web/context/errors" + "github.com/webnice/web/context/handlers" + "github.com/webnice/web/context/route" ) // New returns a new routing context object diff --git a/context/data.go b/context/data.go index c580b95..6053ae0 100644 --- a/context/data.go +++ b/context/data.go @@ -1,7 +1,5 @@ package context -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "bytes" "encoding/json" @@ -12,8 +10,8 @@ import ( runtimeDebug "runtime/debug" "strings" - "gopkg.in/webnice/web.v1/header" - "gopkg.in/webnice/web.v1/mime" + "github.com/webnice/web/header" + "github.com/webnice/web/mime" ) // RegisterGlobalVerifyPlugin Register global external library of data verification diff --git a/context/errors/errors.go b/context/errors/errors.go index ace52a4..9ad4add 100644 --- a/context/errors/errors.go +++ b/context/errors/errors.go @@ -1,8 +1,6 @@ package errors -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import "gopkg.in/webnice/web.v1/ambry" +import "github.com/webnice/web/ambry" // New returns new context object func New() Interface { diff --git a/context/errors/types.go b/context/errors/types.go index 21e822f..7fa9232 100644 --- a/context/errors/types.go +++ b/context/errors/types.go @@ -1,8 +1,6 @@ package errors -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import "gopkg.in/webnice/web.v1/ambry" +import "github.com/webnice/web/ambry" const ( keyRouteConfigurationError uint32 = iota diff --git a/context/handlers/defaults.go b/context/handlers/defaults.go index d1d60ee..99c0c16 100644 --- a/context/handlers/defaults.go +++ b/context/handlers/defaults.go @@ -1,13 +1,11 @@ package handlers -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "net/http" - "gopkg.in/webnice/web.v1/header" - "gopkg.in/webnice/web.v1/mime" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/header" + "github.com/webnice/web/mime" + "github.com/webnice/web/status" ) // Default handler for internal server errors diff --git a/context/handlers/defaults_test.go b/context/handlers/defaults_test.go index 90f7be2..660502f 100644 --- a/context/handlers/defaults_test.go +++ b/context/handlers/defaults_test.go @@ -1,7 +1,5 @@ package handlers -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "io/ioutil" @@ -9,7 +7,7 @@ import ( "net/http/httptest" "testing" - "gopkg.in/webnice/web.v1/context/errors" + "github.com/webnice/web/context/errors" ) func testDefaults(t *testing.T, handler http.HandlerFunc, hfName string, response string) { diff --git a/context/handlers/handlers.go b/context/handlers/handlers.go index 8de2ed2..c948763 100644 --- a/context/handlers/handlers.go +++ b/context/handlers/handlers.go @@ -1,12 +1,10 @@ package handlers -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "net/http" - "gopkg.in/webnice/web.v1/ambry" - "gopkg.in/webnice/web.v1/context/errors" + "github.com/webnice/web/ambry" + "github.com/webnice/web/context/errors" ) // New returns new context object diff --git a/context/handlers/handlers_test.go b/context/handlers/handlers_test.go index 7930538..59de976 100644 --- a/context/handlers/handlers_test.go +++ b/context/handlers/handlers_test.go @@ -1,13 +1,11 @@ package handlers -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "net/http" "testing" - "gopkg.in/webnice/web.v1/context/errors" + "github.com/webnice/web/context/errors" ) type testHandler struct { diff --git a/context/handlers/types.go b/context/handlers/types.go index 1f33020..020df83 100644 --- a/context/handlers/types.go +++ b/context/handlers/types.go @@ -1,12 +1,10 @@ package handlers -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "net/http" - "gopkg.in/webnice/web.v1/ambry" - "gopkg.in/webnice/web.v1/context/errors" + "github.com/webnice/web/ambry" + "github.com/webnice/web/context/errors" ) const ( diff --git a/context/key.go b/context/key.go index c690720..1abfe08 100644 --- a/context/key.go +++ b/context/key.go @@ -1,8 +1,5 @@ package context -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" - // key is a value for use with context.WithValue // It's used as a pointer so it fits in an interface{} without allocation type key struct { diff --git a/context/route/route.go b/context/route/route.go index 6093c31..f33f5f6 100644 --- a/context/route/route.go +++ b/context/route/route.go @@ -1,11 +1,9 @@ package route -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "strings" - "gopkg.in/webnice/web.v1/param" + "github.com/webnice/web/param" ) // New returns a new routing context object diff --git a/context/route/types.go b/context/route/types.go index c5746fd..91de22e 100644 --- a/context/route/types.go +++ b/context/route/types.go @@ -1,8 +1,6 @@ package route -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import "gopkg.in/webnice/web.v1/param" +import "github.com/webnice/web/param" // This is the default routing context set on the root node of a request context to track URL parameters and an optional routing path type impl struct { diff --git a/context/types.go b/context/types.go index 4e65ee2..a8b7336 100644 --- a/context/types.go +++ b/context/types.go @@ -1,13 +1,11 @@ package context -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "net/http" - "gopkg.in/webnice/web.v1/context/errors" - "gopkg.in/webnice/web.v1/context/handlers" - "gopkg.in/webnice/web.v1/context/route" + "github.com/webnice/web/context/errors" + "github.com/webnice/web/context/handlers" + "github.com/webnice/web/context/route" ) var ( diff --git a/errors.go b/errors.go index 1af7fa3..04a1f67 100644 --- a/errors.go +++ b/errors.go @@ -1,8 +1,5 @@ package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" - // All errors are defined as constants const ( cAlreadyRunning = `Web server already running` diff --git a/errors_test.go b/errors_test.go index 8de1b4f..4f55c1f 100644 --- a/errors_test.go +++ b/errors_test.go @@ -1,7 +1,5 @@ package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "strings" "testing" diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..de619c9 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/webnice/web + +go 1.18 diff --git a/header/header_test.go b/header/header_test.go index 2ed5bf4..78347ba 100644 --- a/header/header_test.go +++ b/header/header_test.go @@ -1,5 +1 @@ package header - -//import ( -// -//) diff --git a/listen.go b/listen.go index e31971d..af8a614 100644 --- a/listen.go +++ b/listen.go @@ -1,7 +1,5 @@ package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "crypto/tls" "net" @@ -176,7 +174,7 @@ func (wsv *web) Serve(ltn net.Listener) Interface { return wsv.ServeTLS(ltn, nil func (wsv *web) ServeTLS(ltn net.Listener, tlsConfig *tls.Config) Interface { var conf *Configuration - // TODO: Реализовать поддержку PROXY Protocol через "gopkg.in/webnice/web.v1/proxyp", conf.ProxyProtocol + // TODO: Реализовать поддержку PROXY Protocol через "github.com/webnice/web/proxyp", conf.ProxyProtocol if wsv.conf == nil { conf, _ = parseAddress(ltn.Addr().String()) diff --git a/listen_test.go b/listen_test.go index e681672..a918486 100644 --- a/listen_test.go +++ b/listen_test.go @@ -1,9 +1,8 @@ +//go:build !race // +build !race package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "net" diff --git a/method/method.go b/method/method.go index 663e774..3acd557 100644 --- a/method/method.go +++ b/method/method.go @@ -1,7 +1,5 @@ package method -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "strings" diff --git a/method/method_test.go b/method/method_test.go index 70e3ecc..cd1d4d9 100644 --- a/method/method_test.go +++ b/method/method_test.go @@ -1,7 +1,5 @@ package method -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "strings" "testing" diff --git a/middleware/contentTypeDefault/contentTypeDefault.go b/middleware/contentTypeDefault/contentTypeDefault.go index 21ab842..f40d956 100644 --- a/middleware/contentTypeDefault/contentTypeDefault.go +++ b/middleware/contentTypeDefault/contentTypeDefault.go @@ -1,13 +1,11 @@ package contentTypeDefault -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "io" "net/http" - "gopkg.in/webnice/web.v1/header" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/header" + "github.com/webnice/web/status" ) // Interface is an interface of package diff --git a/middleware/contentTypeDefault/contentTypeDefault_test.go b/middleware/contentTypeDefault/contentTypeDefault_test.go index fed87c1..5abba75 100644 --- a/middleware/contentTypeDefault/contentTypeDefault_test.go +++ b/middleware/contentTypeDefault/contentTypeDefault_test.go @@ -1,7 +1,5 @@ package contentTypeDefault -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "io/ioutil" @@ -9,10 +7,10 @@ import ( "net/http/httptest" "testing" - "gopkg.in/webnice/web.v1/header" - "gopkg.in/webnice/web.v1/mime" - "gopkg.in/webnice/web.v1/route" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/header" + "github.com/webnice/web/mime" + "github.com/webnice/web/route" + "github.com/webnice/web/status" ) func testContentTypeDefaultHandlerFunc1(wr http.ResponseWriter, rq *http.Request) { @@ -43,7 +41,7 @@ func testContentTypeDefault(t *testing.T, rou route.Interface, hf http.HandlerFu err = fmt.Errorf("response HandlerFunc error: %s", err) return } - defer rsp.Body.Close() + defer func() { _ = rsp.Body.Close() }() if buf, err = ioutil.ReadAll(rsp.Body); err != nil { err = fmt.Errorf("read response error: %s", err) diff --git a/middleware/nocache/nocache.go b/middleware/nocache/nocache.go index 579a184..faa7804 100644 --- a/middleware/nocache/nocache.go +++ b/middleware/nocache/nocache.go @@ -1,14 +1,12 @@ package nocache -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "io" "net/http" "time" - "gopkg.in/webnice/web.v1/header" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/header" + "github.com/webnice/web/status" ) type impl struct { diff --git a/middleware/nocache/nocache_test.go b/middleware/nocache/nocache_test.go index 8090ea7..68beccd 100644 --- a/middleware/nocache/nocache_test.go +++ b/middleware/nocache/nocache_test.go @@ -1,7 +1,5 @@ package nocache -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "io/ioutil" @@ -10,20 +8,18 @@ import ( "testing" "time" - "gopkg.in/webnice/web.v1/header" - "gopkg.in/webnice/web.v1/route" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/header" + "github.com/webnice/web/route" + "github.com/webnice/web/status" ) -const ( - ifModifiedSinceTimeFormat = `Mon, 02 Jan 2006 15:04:05 GMT` -) +const ifModifiedSinceTimeFormat = `Mon, 02 Jan 2006 15:04:05 GMT` func testNoCacheHandlerFunc(wr http.ResponseWriter, rq *http.Request) { wr.Header().Add(header.ETag, "686897696a7c876b7e") wr.Header().Set(header.LastModified, time.Now().UTC().Format(ifModifiedSinceTimeFormat)) wr.Header().Set(header.IfUnmodifiedSince, time.Now().UTC().Format(ifModifiedSinceTimeFormat)) - fmt.Fprint(wr, string(status.Bytes(status.Ok))) + _, _ = fmt.Fprint(wr, string(status.Bytes(status.Ok))) wr.WriteHeader(status.Ok) } diff --git a/middleware/pprof/pprof.go b/middleware/pprof/pprof.go index ee2102d..96be2fb 100644 --- a/middleware/pprof/pprof.go +++ b/middleware/pprof/pprof.go @@ -1,16 +1,14 @@ package pprof -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "expvar" "fmt" "net/http" "net/http/pprof" - "gopkg.in/webnice/web.v1/middleware/nocache" - "gopkg.in/webnice/web.v1/route" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/middleware/nocache" + "github.com/webnice/web/route" + "github.com/webnice/web/status" ) // Handler Middleware to profiling diff --git a/middleware/pprof/pprof_test.go b/middleware/pprof/pprof_test.go index dd652ae..713f11a 100644 --- a/middleware/pprof/pprof_test.go +++ b/middleware/pprof/pprof_test.go @@ -1,7 +1,5 @@ package pprof -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "io/ioutil" @@ -10,7 +8,7 @@ import ( "strings" "testing" - "gopkg.in/webnice/web.v1/route" + "github.com/webnice/web/route" ) const testTitleString = `