-
Notifications
You must be signed in to change notification settings - Fork 2
/
source_project_get.go
36 lines (28 loc) · 1.03 KB
/
source_project_get.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
package actions
import (
"net/http"
"github.com/gorilla/mux"
"github.com/ottogroup/penelope/pkg/builder"
"github.com/ottogroup/penelope/pkg/requestobjects"
"go.opencensus.io/trace"
)
type SourceProjectGetHandler struct {
processorBuilder *builder.ProcessorBuilder
}
func NewSourceProjectHandler(processorBuilder *builder.ProcessorBuilder) *SourceProjectGetHandler {
return &SourceProjectGetHandler{processorBuilder: processorBuilder}
}
// ServeHTTP will handle SourceProject operation
func (bl *SourceProjectGetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ctx, span := trace.StartSpan(r.Context(), "SourceProjectGetHandler.ServeHTTP")
defer span.End()
projectID, exist := mux.Vars(r)["project_id"]
if !exist {
msg := "Bad request missing parameter: project_id"
prepareResponse(w, msg, msg, http.StatusBadRequest)
return
}
var request requestobjects.SourceProjectGetRequest
request.Project = projectID
handleRequestByProcessor(ctx, w, r, request, http.StatusOK, bl.processorBuilder.ProcessorForSourceProjectGet)
}