-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
28 lines (23 loc) · 882 Bytes
/
main.go
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
package main
import (
"net/http"
"github.com/alexisvisco/kcd"
)
func main() {
// v status code will be ignored
http.HandleFunc("/example/", kcd.Handler(StandardHttpHandler, http.StatusOK))
http.ListenAndServe(":8080", nil)
}
// StandardHttpHandler is a standard http handler and work with kcd.
// The default status code does not works since you are controlling
// the return via http.ResponseWriter.
//
// This maybe useful in some cases:
// - if you have a large codebase and you want to progressively
// integrate kcd
// - if you have a complex code for instance websocket, sse ...
//
// v as you can see there is no error, and no output struct
func StandardHttpHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("ok"))
}