Renamed module
This commit is contained in:
parent
efa45214c3
commit
45b7bf6714
9
.editorconfig
Normal file
9
.editorconfig
Normal 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
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
# But not these files...
|
# But not these files...
|
||||||
!/.gitignore
|
!/.gitignore
|
||||||
|
!/.editorconfig
|
||||||
|
|
||||||
!*.go
|
!*.go
|
||||||
!go.sum
|
!go.sum
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package aero
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
22
README.md
22
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)
|
||||||
|
```
|
@ -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
2
go.mod
@ -1,4 +1,4 @@
|
|||||||
module git.akyoto.dev/go/aero
|
module git.akyoto.dev/go/server
|
||||||
|
|
||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user