handle /item redirect
This commit is contained in:
parent
a49346bda4
commit
9f9f43751f
1 changed files with 6 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/maddalax/htmgo/framework/h"
|
"github.com/maddalax/htmgo/framework/h"
|
||||||
"github.com/maddalax/htmgo/framework/service"
|
"github.com/maddalax/htmgo/framework/service"
|
||||||
"hackernews/__htmgo"
|
"hackernews/__htmgo"
|
||||||
|
|
@ -23,6 +24,11 @@ func main() {
|
||||||
|
|
||||||
http.FileServerFS(sub)
|
http.FileServerFS(sub)
|
||||||
|
|
||||||
|
app.Router.Handle("/item", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
id := r.URL.Query().Get("id")
|
||||||
|
w.Header().Set("Location", fmt.Sprintf("/?item=%s", id))
|
||||||
|
w.WriteHeader(302)
|
||||||
|
}))
|
||||||
app.Router.Handle("/public/*", http.StripPrefix("/public", http.FileServerFS(sub)))
|
app.Router.Handle("/public/*", http.StripPrefix("/public", http.FileServerFS(sub)))
|
||||||
__htmgo.Register(app.Router)
|
__htmgo.Register(app.Router)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue