Finish first working version of reqlog

This commit is contained in:
David Stotijn
2020-09-19 01:27:55 +02:00
parent c5cf6ef867
commit 211c11be2b
10 changed files with 646 additions and 280 deletions

View File

@ -9,27 +9,48 @@ import (
"time"
)
type Request struct {
URL string `json:"url"`
Method HTTPMethod `json:"method"`
Timestamp time.Time `json:"timestamp"`
type HTTPRequest struct {
URL string `json:"url"`
Method HTTPMethod `json:"method"`
Body *string `json:"body"`
Timestamp time.Time `json:"timestamp"`
Response *HTTPResponse `json:"response"`
}
type HTTPResponse struct {
StatusCode int `json:"statusCode"`
Body *string `json:"body"`
}
type HTTPMethod string
const (
HTTPMethodGet HTTPMethod = "GET"
HTTPMethodPost HTTPMethod = "POST"
HTTPMethodGet HTTPMethod = "GET"
HTTPMethodHead HTTPMethod = "HEAD"
HTTPMethodPost HTTPMethod = "POST"
HTTPMethodPut HTTPMethod = "PUT"
HTTPMethodDelete HTTPMethod = "DELETE"
HTTPMethodConnect HTTPMethod = "CONNECT"
HTTPMethodOptions HTTPMethod = "OPTIONS"
HTTPMethodTrace HTTPMethod = "TRACE"
HTTPMethodPatch HTTPMethod = "PATCH"
)
var AllHTTPMethod = []HTTPMethod{
HTTPMethodGet,
HTTPMethodHead,
HTTPMethodPost,
HTTPMethodPut,
HTTPMethodDelete,
HTTPMethodConnect,
HTTPMethodOptions,
HTTPMethodTrace,
HTTPMethodPatch,
}
func (e HTTPMethod) IsValid() bool {
switch e {
case HTTPMethodGet, HTTPMethodPost:
case HTTPMethodGet, HTTPMethodHead, HTTPMethodPost, HTTPMethodPut, HTTPMethodDelete, HTTPMethodConnect, HTTPMethodOptions, HTTPMethodTrace, HTTPMethodPatch:
return true
}
return false