-
Notifications
You must be signed in to change notification settings - Fork 0
/
testgrp.go
35 lines (30 loc) · 838 Bytes
/
testgrp.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
// Package testgrp contains all the test handlers
package testgrp
import (
"context"
"errors"
"github.com/jcsix694/service3-video/business/sys/validate"
"github.com/jcsix694/service3-video/foundation/web"
"go.uber.org/zap"
"math/rand"
"net/http"
)
// Handlers manages the set of check endpoints
type Handlers struct {
Log *zap.SugaredLogger
}
// Test handle for development
func (h Handlers) Test(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
if n := rand.Intn(100); n%2 == 0 {
// return errors.New("untrusted error")
return validate.NewRequestError(errors.New("trusted error"), http.StatusBadRequest)
// return web.NewShutdownError("Restart Service")
// panic("testing panic")
}
status := struct {
Status string
}{
Status: "OK",
}
return web.Respond(ctx, w, status, http.StatusOK)
}