From ea552b91980d3d3efb4aa1e7122d5501e5805815 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Tue, 18 Jul 2023 21:48:38 +0200 Subject: [PATCH] Renamed module --- .editorconfig | 9 +++++++++ .gitignore | 1 + Context.go | 2 +- README.md | 22 ++++++++++++++++++++-- Server.go | 2 +- Server_test.go | 14 +++++++------- go.mod | 2 +- pool.go | 2 +- 8 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2b4f594 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = false \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7c62cc2..96914ed 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ # But not these files... !/.gitignore +!/.editorconfig !*.go !go.sum diff --git a/Context.go b/Context.go index 4d4e1a6..8c07b97 100644 --- a/Context.go +++ b/Context.go @@ -1,4 +1,4 @@ -package aero +package server import ( "net/http" diff --git a/README.md b/README.md index 25e3590..9103230 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ -# aero +# server -High-performance web framework. +HTTP server. + +## Installation + +```shell +go get git.akyoto.dev/go/server +``` + +## Example + +```go +s := server.New() + +s.Get("/", func(ctx server.Context) error { + return ctx.String("Hello") +}) + +http.ListenAndServe(":8080", s) +``` \ No newline at end of file diff --git a/Server.go b/Server.go index d6299f8..51eaa78 100644 --- a/Server.go +++ b/Server.go @@ -1,4 +1,4 @@ -package aero +package server import ( "fmt" diff --git a/Server_test.go b/Server_test.go index 94ceeda..c33f9cf 100644 --- a/Server_test.go +++ b/Server_test.go @@ -1,4 +1,4 @@ -package aero_test +package server_test import ( "errors" @@ -7,22 +7,22 @@ import ( "net/http/httptest" "testing" - "git.akyoto.dev/go/aero" "git.akyoto.dev/go/assert" + "git.akyoto.dev/go/server" ) func TestServer(t *testing.T) { - server := aero.New() + s := server.New() - server.Get("/", func(ctx aero.Context) error { + s.Get("/", func(ctx server.Context) error { return ctx.Bytes([]byte("Hello")) }) - server.Get("/blog/:post", func(ctx aero.Context) error { + s.Get("/blog/:post", func(ctx server.Context) error { return ctx.Bytes([]byte("Hello")) }) - server.Get("/error", func(ctx aero.Context) error { + s.Get("/error", func(ctx server.Context) error { return ctx.Error(http.StatusUnauthorized, errors.New("Not logged in")) }) @@ -41,7 +41,7 @@ func TestServer(t *testing.T) { t.Run("example.com"+test.URL, func(t *testing.T) { request := httptest.NewRequest(http.MethodGet, test.URL, nil) response := httptest.NewRecorder() - server.ServeHTTP(response, request) + s.ServeHTTP(response, request) result := response.Result() assert.Equal(t, result.StatusCode, test.Status) diff --git a/go.mod b/go.mod index a8709a7..bf65f10 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module git.akyoto.dev/go/aero +module git.akyoto.dev/go/server go 1.20 diff --git a/pool.go b/pool.go index 6cb772b..5652235 100644 --- a/pool.go +++ b/pool.go @@ -1,4 +1,4 @@ -package aero +package server import "sync"