Skip to content

Releases: lonng/nex

v1.4.1

15 Sep 14:51
Compare
Choose a tag to compare
Update adatper.go

feature: handler group

10 Sep 09:36
Compare
Choose a tag to compare
  1. Handler group. ref: fed0eeb
  2. Override default response body encoder. ref: 3e43f18

Performance improvement

15 Aug 06:36
Compare
Choose a tag to compare
v1.3.0

Merge branch 'master' of https://github.com/chrislonng/nex

context.Context support

13 May 11:06
Compare
Choose a tag to compare

context.Context support

func main() {
	logic := func(ctx context.Context) (context.Context, *testResponse, error) {
		println(ctx.Value("key").(string))
		println(ctx.Value("key2").(string))
		return context.WithValue(ctx, "logic", "logic-value"), &testResponse{}, nil
	}

	before1 := func(ctx context.Context, request *http.Request) (context.Context, error) {
		return context.WithValue(ctx, "key", "value"), nil
	}

	before2 := func(ctx context.Context, request *http.Request) (context.Context, error) {
		println(ctx.Value("key").(string))
		return context.WithValue(ctx, "key2", "value2"), nil
	}

	after1 := func(ctx context.Context, w http.ResponseWriter) (context.Context, error) {
		println(ctx.Value("key").(string))
		println(ctx.Value("key2").(string))
		println(ctx.Value("logic").(string))

		return context.WithValue(ctx, "after1", "after1-value"), nil
	}

	after2 := func(ctx context.Context, w http.ResponseWriter) (context.Context, error) {
		println(ctx.Value("key").(string))
		println(ctx.Value("key2").(string))
		println(ctx.Value("logic").(string))
		println(ctx.Value("after1").(string))

		return context.WithValue(ctx, "key", "value"), nil
	}

	handler := Handler(logic).Before(before1, before2).After(after1, after2)

	handler.ServeHTTP(w, r)
}

middleware support

04 Feb 09:24
Compare
Choose a tag to compare
  1. middleware support
  2. helper method for url.Values

v1.0.0

21 Jan 03:53
Compare
Choose a tag to compare
change benchmark