Renamed module

This commit is contained in:
Eduard Urbach 2023-07-18 21:48:38 +02:00
parent efa45214c3
commit 45b7bf6714
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
8 changed files with 41 additions and 13 deletions

9
.editorconfig Normal file
View File

@ -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

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
# But not these files... # But not these files...
!/.gitignore !/.gitignore
!/.editorconfig
!*.go !*.go
!go.sum !go.sum

View File

@ -1,4 +1,4 @@
package aero package server
import ( import (
"net/http" "net/http"

View File

@ -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)
```

View File

@ -1,4 +1,4 @@
package aero package server
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package aero_test package server_test
import ( import (
"errors" "errors"
@ -7,22 +7,22 @@ import (
"net/http/httptest" "net/http/httptest"
"testing" "testing"
"git.akyoto.dev/go/aero"
"git.akyoto.dev/go/assert" "git.akyoto.dev/go/assert"
"git.akyoto.dev/go/server"
) )
func TestServer(t *testing.T) { 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")) 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")) 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")) 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) { t.Run("example.com"+test.URL, func(t *testing.T) {
request := httptest.NewRequest(http.MethodGet, test.URL, nil) request := httptest.NewRequest(http.MethodGet, test.URL, nil)
response := httptest.NewRecorder() response := httptest.NewRecorder()
server.ServeHTTP(response, request) s.ServeHTTP(response, request)
result := response.Result() result := response.Result()
assert.Equal(t, result.StatusCode, test.Status) assert.Equal(t, result.StatusCode, test.Status)

2
go.mod
View File

@ -1,4 +1,4 @@
module git.akyoto.dev/go/aero module git.akyoto.dev/go/server
go 1.20 go 1.20

View File

@ -1,4 +1,4 @@
package aero package server
import "sync" import "sync"