-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (28 loc) · 857 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
29
30
31
32
33
34
35
36
37
package main
import (
"fmt"
"net/http"
"github.com/hyperdriven/hyperdrive"
)
type ExampleEndpoint struct {
hyperdrive.Endpoint
}
func (e *ExampleEndpoint) Get(rw http.ResponseWriter, r *http.Request) {
fmt.Fprintln(rw, "hello world")
return
}
var Example = &ExampleEndpoint{*hyperdrive.NewEndpoint("Example Endpoint", "Example Endpoint, written with hyperdriven/hyperdrive", "/example", "1")}
type PanicEndpoint struct {
hyperdrive.Endpoint
}
func (e *PanicEndpoint) Get(rw http.ResponseWriter, r *http.Request) {
panic("ERROR! Everyone panic!")
return
}
var PanicExample = &PanicEndpoint{*hyperdrive.NewEndpoint("Panic Endpoint", "This example tests panic recovery.", "/panic", "1")}
func main() {
api := hyperdrive.NewAPI("Example API", "Example API Description")
api.AddEndpoint(Example)
api.AddEndpoint(PanicExample)
api.Start()
}