-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (32 loc) · 746 Bytes
/
main.go
File metadata and controls
36 lines (32 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"log"
"net/http"
"time"
"github.com/go-chi/chi"
"github.com/induzo/crud/mock"
"github.com/induzo/crud/rest"
)
func main() {
r := chi.NewRouter()
// Subrouters:
m := mock.NewMgr()
r.Route("/e", func(r chi.Router) {
r.Get("/", rest.GETListHandler(m))
r.Post("/", rest.POSTHandler(m))
r.Get("/{ID}", rest.GETHandler(m))
r.Patch("/{ID}", rest.PATCHHandler(m))
r.Put("/{ID}", rest.PUTHandler(m))
r.Delete("/{ID}", rest.DELETEHandler(m))
})
srv := &http.Server{
ReadTimeout: 10 * time.Second,
WriteTimeout: 7200 * time.Second,
IdleTimeout: 10 * time.Second,
Addr: ":8080",
Handler: r,
}
if err := srv.ListenAndServe(); err != nil {
log.Fatalf("server error: %v", err)
}
}