Updated dependencies
This commit is contained in:
parent
c179ca6651
commit
d6de510d6e
13
Context.go
13
Context.go
@ -5,6 +5,8 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"git.akyoto.dev/go/router"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Context represents the interface for a request & response context.
|
// Context represents the interface for a request & response context.
|
||||||
@ -33,7 +35,7 @@ type ctx struct {
|
|||||||
request *http.Request
|
request *http.Request
|
||||||
response http.ResponseWriter
|
response http.ResponseWriter
|
||||||
server *server
|
server *server
|
||||||
params []param
|
params []router.Parameter
|
||||||
handlerCount uint8
|
handlerCount uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +66,7 @@ func (ctx *ctx) Get(param string) string {
|
|||||||
for i := range len(ctx.params) {
|
for i := range len(ctx.params) {
|
||||||
p := ctx.params[i]
|
p := ctx.params[i]
|
||||||
|
|
||||||
if p.Name == param {
|
if p.Key == param {
|
||||||
return p.Value
|
return p.Value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,6 +149,9 @@ func (ctx *ctx) WriteString(body string) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// addParameter adds a new parameter to the context.
|
// addParameter adds a new parameter to the context.
|
||||||
func (ctx *ctx) addParameter(name string, value string) {
|
func (ctx *ctx) addParameter(key string, value string) {
|
||||||
ctx.params = append(ctx.params, param{name, value})
|
ctx.params = append(ctx.params, router.Parameter{
|
||||||
|
Key: key,
|
||||||
|
Value: value,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
11
README.md
11
README.md
@ -4,6 +4,7 @@ HTTP server.
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
- High performance
|
||||||
- Low latency
|
- Low latency
|
||||||
- Radix tree routing
|
- Radix tree routing
|
||||||
|
|
||||||
@ -50,11 +51,11 @@ coverage: 100.0% of statements
|
|||||||
## Benchmarks
|
## Benchmarks
|
||||||
|
|
||||||
```
|
```
|
||||||
BenchmarkStatic/#00-12 36761953 31.12 ns/op 0 B/op 0 allocs/op
|
BenchmarkStatic/#00-12 34907296 30.19 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkStatic/hello-12 28145253 41.21 ns/op 0 B/op 0 allocs/op
|
BenchmarkStatic/hello-12 27628322 40.89 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkStatic/hello/world-12 21206058 55.10 ns/op 0 B/op 0 allocs/op
|
BenchmarkStatic/hello/world-12 21330940 56.24 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkGitHub/gists/:id-12 21452644 52.65 ns/op 0 B/op 0 allocs/op
|
BenchmarkGitHub/gists/:id-12 23608254 50.86 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkGitHub/repos/:a/:b-12 17888092 61.59 ns/op 0 B/op 0 allocs/op
|
BenchmarkGitHub/repos/:a/:b-12 18912602 59.02 ns/op 0 B/op 0 allocs/op
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
@ -62,7 +62,7 @@ func New() Server {
|
|||||||
s.pool.New = func() any {
|
s.pool.New = func() any {
|
||||||
return &ctx{
|
return &ctx{
|
||||||
server: s,
|
server: s,
|
||||||
params: make([]param, 0, 8),
|
params: make([]router.Parameter, 0, 8),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
go.mod
2
go.mod
@ -4,5 +4,5 @@ go 1.22
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
git.akyoto.dev/go/assert v0.1.3
|
git.akyoto.dev/go/assert v0.1.3
|
||||||
git.akyoto.dev/go/router v0.1.3
|
git.akyoto.dev/go/router v0.1.4
|
||||||
)
|
)
|
||||||
|
4
go.sum
4
go.sum
@ -1,4 +1,4 @@
|
|||||||
git.akyoto.dev/go/assert v0.1.3 h1:QwCUbmG4aZYsNk/OuRBz1zWVKmGlDUHhOnnDBfn8Qw8=
|
git.akyoto.dev/go/assert v0.1.3 h1:QwCUbmG4aZYsNk/OuRBz1zWVKmGlDUHhOnnDBfn8Qw8=
|
||||||
git.akyoto.dev/go/assert v0.1.3/go.mod h1:0GzMaM0eURuDwtGkJJkCsI7r2aUKr+5GmWNTFPgDocM=
|
git.akyoto.dev/go/assert v0.1.3/go.mod h1:0GzMaM0eURuDwtGkJJkCsI7r2aUKr+5GmWNTFPgDocM=
|
||||||
git.akyoto.dev/go/router v0.1.3 h1:H4wJCYdDD3/i9miYSK/e5sCoGiXe9OX7KmgH4/Toa60=
|
git.akyoto.dev/go/router v0.1.4 h1:ZL5HPl4aNn4QKihf3VVs0Mm9R6ZGn2StAHGRQxjEbws=
|
||||||
git.akyoto.dev/go/router v0.1.3/go.mod h1:VfSsK/Z6fUhT3pWaAAnuAcj++bWRZD+bzNaqJoTAunU=
|
git.akyoto.dev/go/router v0.1.4/go.mod h1:rbHbkLJlQOafuOuvBalO3O8E0JtMFPT3zzTKX3h9T08=
|
||||||
|
Loading…
Reference in New Issue
Block a user