feat: new release of version 4
This commit is contained in:
parent
18a84b9b92
commit
7b5e1d0254
2 changed files with 5 additions and 5 deletions
|
@ -13,7 +13,7 @@ httprouter is a framework used for HTTP request routing.
|
||||||
|
|
||||||
Just replace the standard router of golang with this one:
|
Just replace the standard router of golang with this one:
|
||||||
```golang
|
```golang
|
||||||
import "git.martin-riedl.de/golang/httprouter/v3"
|
import "git.martin-riedl.de/golang/httprouter/v4"
|
||||||
```
|
```
|
||||||
```golang
|
```golang
|
||||||
router := httprouter.New()
|
router := httprouter.New()
|
||||||
|
@ -27,7 +27,7 @@ err := http.ListenAndServe("localhost:8080", router)
|
||||||
|
|
||||||
A path can also contain placeholder (like :id). If then a request is sent to the url "/user/123" the method gets executed and the URL part (in this case "123") is passed as parameter into your handler function.
|
A path can also contain placeholder (like :id). If then a request is sent to the url "/user/123" the method gets executed and the URL part (in this case "123") is passed as parameter into your handler function.
|
||||||
```golang
|
```golang
|
||||||
import "git.martin-riedl.de/golang/httprouter/v3"
|
import "git.martin-riedl.de/golang/httprouter/v4"
|
||||||
```
|
```
|
||||||
```golang
|
```golang
|
||||||
router := httprouter.New()
|
router := httprouter.New()
|
||||||
|
@ -44,7 +44,7 @@ err := http.ListenAndServe("localhost:8080", router)
|
||||||
|
|
||||||
Static files (like JavaScript or CSS) can be served automatically (including caching header and MIME type). It uses the `embed.FS` (since go 1.16) to serve static content.
|
Static files (like JavaScript or CSS) can be served automatically (including caching header and MIME type). It uses the `embed.FS` (since go 1.16) to serve static content.
|
||||||
```golang
|
```golang
|
||||||
import "git.martin-riedl.de/golang/httprouter/v3"
|
import "git.martin-riedl.de/golang/httprouter/v4"
|
||||||
|
|
||||||
//go:embed files/static/*
|
//go:embed files/static/*
|
||||||
var staticFiles embed.FS
|
var staticFiles embed.FS
|
||||||
|
@ -60,7 +60,7 @@ The framework checks first, if the file exists locally and serves it directly.
|
||||||
If not, the file is served from the `embed.FS`.
|
If not, the file is served from the `embed.FS`.
|
||||||
This helps you during local development so you can modify a CSS file without recompiling everything.
|
This helps you during local development so you can modify a CSS file without recompiling everything.
|
||||||
```golang
|
```golang
|
||||||
import "git.martin-riedl.de/golang/httprouter/v3"
|
import "git.martin-riedl.de/golang/httprouter/v4"
|
||||||
```
|
```
|
||||||
```golang
|
```golang
|
||||||
staticFS := httprouter.NewFS(&staticFiles)
|
staticFS := httprouter.NewFS(&staticFiles)
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1,3 +1,3 @@
|
||||||
module git.martin-riedl.de/golang/httprouter/v3
|
module git.martin-riedl.de/golang/httprouter/v4
|
||||||
|
|
||||||
go 1.19
|
go 1.19
|
Loading…
Add table
Reference in a new issue