Skip to content

Commit

Permalink
use v3 instead of v2
Browse files Browse the repository at this point in the history
  • Loading branch information
xgfone committed Jul 4, 2020
1 parent 783ecc3 commit 1f58ac0
Show file tree
Hide file tree
Showing 31 changed files with 59 additions and 59 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# ship [![Build Status](https://travis-ci.org/xgfone/ship.svg?branch=master)](https://travis-ci.org/xgfone/ship) [![GoDoc](https://godoc.org/github.com/xgfone/ship?status.svg)](https://pkg.go.dev/github.com/xgfone/ship/v2) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square)](https://raw.githubusercontent.com/xgfone/ship/master/LICENSE)
# ship [![Build Status](https://travis-ci.org/xgfone/ship.svg?branch=master)](https://travis-ci.org/xgfone/ship) [![GoDoc](https://godoc.org/github.com/xgfone/ship?status.svg)](https://pkg.go.dev/github.com/xgfone/ship/v3) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square)](https://raw.githubusercontent.com/xgfone/ship/master/LICENSE)

`ship` is a flexible, powerful, high performance and minimalist Go Web HTTP router framework. It is inspired by [echo](https://github.com/labstack/echo) and [httprouter](https://github.com/julienschmidt/httprouter). Thanks for those contributors.

`ship` has been stable, and the current version is `v2` and support Go `1.11+`.
`ship` has been stable, and the current version is `v3` and support Go `1.11+`.


## Install

```shell
go get -u github.com/xgfone/ship/v2
go get -u github.com/xgfone/ship/v3
```


Expand All @@ -18,7 +18,7 @@ go get -u github.com/xgfone/ship/v2
// example.go
package main

import "github.com/xgfone/ship/v2"
import "github.com/xgfone/ship/v3"

func main() {
router := ship.New()
Expand Down Expand Up @@ -126,7 +126,7 @@ package main
import (
"net/http"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

type TestType struct{}
Expand Down Expand Up @@ -225,8 +225,8 @@ package main
import (
"net/http"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v2/middleware"
"github.com/xgfone/ship/v3"
"github.com/xgfone/ship/v3/middleware"
)

func main() {
Expand All @@ -246,8 +246,8 @@ package main
import (
"net/http"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v2/middleware"
"github.com/xgfone/ship/v3"
"github.com/xgfone/ship/v3/middleware"
)

func RemovePathPrefix(prefix string) ship.Middleware {
Expand Down Expand Up @@ -281,7 +281,7 @@ func main() {
```go
package main

import "github.com/xgfone/ship/v2"
import "github.com/xgfone/ship/v3"

func main() {
router := ship.New()
Expand Down Expand Up @@ -316,7 +316,7 @@ package main
import (
"net/http"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

func responder(ctx *ship.Context, args ...interface{}) error {
Expand Down Expand Up @@ -395,9 +395,9 @@ package main
import (
"fmt"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v2/render"
"github.com/xgfone/ship/v2/render/template"
"github.com/xgfone/ship/v3"
"github.com/xgfone/ship/v3/render"
"github.com/xgfone/ship/v3/render/template"
)

func main() {
Expand Down Expand Up @@ -459,7 +459,7 @@ package main

import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

func main() {
Expand All @@ -476,7 +476,7 @@ package main
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

// DisableBuiltinCollector removes the collectors that the default prometheus
Expand All @@ -501,7 +501,7 @@ package main
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/expfmt"
"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

// DisableBuiltinCollector removes the collectors that the default prometheus
Expand Down Expand Up @@ -549,9 +549,9 @@ func main() {

## Route Management

`ship` supply a default implementation based on [Radix tree](https://en.wikipedia.org/wiki/Radix_tree) to manage the route with **Zero Garbage** (See [Benchmark](#benchmark)), which refers to [echo](https://github.com/labstack/echo), that's, [`NewRouter()`](https://pkg.go.dev/github.com/xgfone/ship/v2/router/echo?tab=doc#NewRouter).
`ship` supply a default implementation based on [Radix tree](https://en.wikipedia.org/wiki/Radix_tree) to manage the route with **Zero Garbage** (See [Benchmark](#benchmark)), which refers to [echo](https://github.com/labstack/echo), that's, [`NewRouter()`](https://pkg.go.dev/github.com/xgfone/ship/v3/router/echo?tab=doc#NewRouter).

You can appoint your own implementation by implementing the interface [`Router`](https://pkg.go.dev/github.com/xgfone/ship/v2/router?tab=doc#Router).
You can appoint your own implementation by implementing the interface [`Router`](https://pkg.go.dev/github.com/xgfone/ship/v3/router?tab=doc#Router).

```go
type Router interface {
Expand Down
6 changes: 3 additions & 3 deletions _benchmark/go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module github.com/xgfone/ship/v2/_benchmark
module github.com/xgfone/ship/v3/_benchmark

require (
github.com/gin-gonic/gin v1.5.0
github.com/labstack/echo/v4 v4.1.11
github.com/xgfone/ship/v2 v2.0.0
github.com/xgfone/ship/v3 v3.0.0
)

replace github.com/xgfone/ship/v2 => ../
replace github.com/xgfone/ship/v3 => ../

go 1.11
2 changes: 1 addition & 1 deletion _benchmark/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/gin-gonic/gin"
"github.com/labstack/echo/v4"
"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

func loadEchoRoutes(e *echo.Echo, routes []*Route) {
Expand Down
2 changes: 1 addition & 1 deletion binder/binder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"net/http"
"strings"

"github.com/xgfone/ship/v2/herror"
"github.com/xgfone/ship/v3/herror"
)

// Binder is the interface to bind the value to v from ctx.
Expand Down
2 changes: 1 addition & 1 deletion binder/binder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"testing"
"time"

"github.com/xgfone/ship/v2/herror"
"github.com/xgfone/ship/v3/herror"
)

var testMuxBinder = NewMuxBinder()
Expand Down
8 changes: 4 additions & 4 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import (
"strconv"
"strings"

"github.com/xgfone/ship/v2/binder"
"github.com/xgfone/ship/v2/render"
"github.com/xgfone/ship/v2/router"
"github.com/xgfone/ship/v2/session"
"github.com/xgfone/ship/v3/binder"
"github.com/xgfone/ship/v3/render"
"github.com/xgfone/ship/v3/router"
"github.com/xgfone/ship/v3/session"
)

// MaxMemoryLimit is the maximum memory.
Expand Down
2 changes: 1 addition & 1 deletion error.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package ship
import (
"fmt"

"github.com/xgfone/ship/v2/herror"
"github.com/xgfone/ship/v3/herror"
)

// Re-export some errors.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/xgfone/ship/v2
module github.com/xgfone/ship/v3

go 1.11
2 changes: 1 addition & 1 deletion middleware/body_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"io"
"sync"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

// BodyLimit is used to limit the maximum body of the request.
Expand Down
2 changes: 1 addition & 1 deletion middleware/body_limit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"net/http/httptest"
"testing"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

func TestBodyLimitReader(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion middleware/cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"net/http"
"strings"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

// CORSConfig is used to configure the CORS middleware.
Expand Down
2 changes: 1 addition & 1 deletion middleware/cors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"net/http/httptest"
"testing"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

// Refer to github.com/labstack/echo/middleware#TestCORS
Expand Down
2 changes: 1 addition & 1 deletion middleware/csrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"net/http"
"time"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

// CSRFConfig is used to configure the CSRF middleware.
Expand Down
2 changes: 1 addition & 1 deletion middleware/csrf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strings"
"testing"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

func TestCSRF(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion middleware/gzip_compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"net/http"
"strings"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

// Gzip returns a middleware to compress the response body by GZIP.
Expand Down
2 changes: 1 addition & 1 deletion middleware/gzip_compress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"
"testing"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

func TestGzip(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion middleware/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"net/http"
"time"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

// Logger returns a new logger middleware that will log the request.
Expand Down
2 changes: 1 addition & 1 deletion middleware/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strings"
"testing"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

func TestLogger(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion middleware/max_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"net/http"
"sync/atomic"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

// MaxRequests returns a Middleware to allow the maximum number of the requests
Expand Down
2 changes: 1 addition & 1 deletion middleware/max_requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"testing"
"time"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

func TestMaxRequests(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"time"
"unicode"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion middleware/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package middleware

import (
"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

// CleanPath returns a new middleware to clean the request path.
Expand Down
2 changes: 1 addition & 1 deletion middleware/recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package middleware
import (
"fmt"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

// Recover returns a middleware to wrap the panic.
Expand Down
2 changes: 1 addition & 1 deletion middleware/recover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"net/http/httptest"
"testing"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

func TestRecover(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion middleware/request_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package middleware

import (
"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

// RequestID returns a X-Request-ID middleware.
Expand Down
2 changes: 1 addition & 1 deletion middleware/token_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package middleware
import (
"net/http"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

// TokenAuth returns a TokenAuth middleware.
Expand Down
2 changes: 1 addition & 1 deletion middleware/token_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strings"
"testing"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

func TestAuthToken(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion middleware/trailing_slash.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package middleware
import (
"strings"

"github.com/xgfone/ship/v2"
"github.com/xgfone/ship/v3"
)

// RemoveTrailingSlash returns a new middleware to remove the trailing slash
Expand Down
2 changes: 1 addition & 1 deletion router/echo/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"strings"
"sync"

"github.com/xgfone/ship/v2/router"
"github.com/xgfone/ship/v3/router"
)

// PROPFIND Method can be used on collection and property resources.
Expand Down
Loading

0 comments on commit 1f58ac0

Please sign in to comment.