-
Notifications
You must be signed in to change notification settings - Fork 0
/
documentehandletext.go
52 lines (45 loc) · 1.16 KB
/
documentehandletext.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"net/http"
)
// DocumentHandleText handle incoming request by http Method
type DocumentHandleText struct {
Document DocumentDescriptor
}
// New initialize
func (d *DocumentHandleText) New(document DocumentDescriptor) {
d.Document = document
}
//Get GET verb
func (d *DocumentHandleText) Get(key string) HTTPResponse {
response := fmt.Sprintf("%v", *d.Document.ResponseBody)
return HTTPResponse{
Status: http.StatusOK,
Body: response,
}
}
//Delete DELETE verb
func (d *DocumentHandleText) Delete(key string) HTTPResponse {
response := "DELETE method not allowed with non iterable data"
return HTTPResponse{
Status: http.StatusMethodNotAllowed,
Body: response,
}
}
// Post POST verb
func (d *DocumentHandleText) Post(payload string) HTTPResponse {
response := "POST method not allowed with non iterable data"
return HTTPResponse{
Status: http.StatusMethodNotAllowed,
Body: response,
}
}
//Put PUT verb
func (d *DocumentHandleText) Put(key string, payload string) HTTPResponse {
response := "PUT method not allowed with non iterable data"
return HTTPResponse{
Status: http.StatusMethodNotAllowed,
Body: response,
}
}