Updated documentation

This commit is contained in:
Eduard Urbach 2024-03-07 18:17:01 +01:00
parent 0ce58609c1
commit 070b374c6e
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0

View File

@ -4,7 +4,8 @@ HTTP server.
## Features ## Features
- Specificity based routing - Low latency
- Radix tree routing
## Installation ## Installation
@ -17,33 +18,22 @@ go get git.akyoto.dev/go/server
```go ```go
s := server.New() s := server.New()
// Add your routes here. // Static route
http.ListenAndServe(":8080", s)
```
### Static
```go
s.Get("/", func(ctx server.Context) error { s.Get("/", func(ctx server.Context) error {
return ctx.String("Hello") return ctx.String("Hello")
}) })
```
### Parameter // Parameter route
```go
s.Get("/blog/:post", func(ctx server.Context) error { s.Get("/blog/:post", func(ctx server.Context) error {
return ctx.String(ctx.Get("post")) return ctx.String(ctx.Get("post"))
}) })
```
### Wildcard // Wildcard route
```go
s.Get("/images/*file", func(ctx server.Context) error { s.Get("/images/*file", func(ctx server.Context) error {
return ctx.String(ctx.Get("file")) return ctx.String(ctx.Get("file"))
}) })
http.ListenAndServe(":8080", s)
``` ```
## Tests ## Tests
@ -57,6 +47,7 @@ coverage: 100.0% of statements
## Benchmarks ## Benchmarks
``` ```
coming soon
``` ```
## License ## License