summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-15 15:54:14 +0300
committerWolfy-J <[email protected]>2018-06-15 15:54:14 +0300
commitdfef39c64132192d13e2315364a74f1b0244791e (patch)
treeb0959bbbb1ca5a16d94646454d7f2e9340081915 /service
parentccd297dbe2586b3fd29854f72f795be9e818522e (diff)
readme, samples, golint, build scripts
Diffstat (limited to 'service')
-rw-r--r--service/http/config.go2
-rw-r--r--service/http/handler.go10
-rw-r--r--service/http/request.go6
-rw-r--r--service/http/service.go1
-rw-r--r--service/http/uploads.go13
-rw-r--r--service/http/uploads_config.go2
-rw-r--r--service/service.go2
-rw-r--r--service/static/config.go2
8 files changed, 20 insertions, 18 deletions
diff --git a/service/http/config.go b/service/http/config.go
index de791f45..fb4574b1 100644
--- a/service/http/config.go
+++ b/service/http/config.go
@@ -6,7 +6,7 @@ import (
"strings"
)
-// Configures RoadRunner HTTP server.
+// Config configures RoadRunner HTTP server.
type Config struct {
// Enable enables http svc.
Enable bool
diff --git a/service/http/handler.go b/service/http/handler.go
index 2c7c1fad..6f2617b1 100644
--- a/service/http/handler.go
+++ b/service/http/handler.go
@@ -21,8 +21,8 @@ type Event struct {
// Method of the request.
Method string
- // Uri requested by the client.
- Uri string
+ // URI requested by the client.
+ URI string
// Status is response status.
Status int
@@ -40,7 +40,7 @@ type Handler struct {
lsn func(event int, ctx interface{})
}
-// AddListener attaches pool event watcher.
+// Listen attaches handler event watcher.
func (h *Handler) Listen(l func(event int, ctx interface{})) {
h.mul.Lock()
defer h.mul.Unlock()
@@ -99,7 +99,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// handleError sends error.
func (h *Handler) handleError(w http.ResponseWriter, r *http.Request, err error) {
- h.throw(EventError, &Event{Method: r.Method, Uri: uri(r), Status: 500, Error: err})
+ h.throw(EventError, &Event{Method: r.Method, URI: uri(r), Status: 500, Error: err})
w.WriteHeader(500)
w.Write([]byte(err.Error()))
@@ -107,7 +107,7 @@ func (h *Handler) handleError(w http.ResponseWriter, r *http.Request, err error)
// handleResponse triggers response event.
func (h *Handler) handleResponse(req *Request, resp *Response) {
- h.throw(EventResponse, &Event{Method: req.Method, Uri: req.Uri, Status: resp.Status})
+ h.throw(EventResponse, &Event{Method: req.Method, URI: req.URI, Status: resp.Status})
}
// throw invokes event srv if any.
diff --git a/service/http/request.go b/service/http/request.go
index 2e8ae090..3082eeb5 100644
--- a/service/http/request.go
+++ b/service/http/request.go
@@ -26,8 +26,8 @@ type Request struct {
// Method contains name of HTTP method used for the request.
Method string `json:"method"`
- // Uri contains full request Uri with scheme and query.
- Uri string `json:"uri"`
+ // URI contains full request URI with scheme and query.
+ URI string `json:"uri"`
// Headers contains list of request headers.
Headers http.Header `json:"headers"`
@@ -53,7 +53,7 @@ func NewRequest(r *http.Request, cfg *UploadsConfig) (req *Request, err error) {
req = &Request{
Protocol: r.Proto,
Method: r.Method,
- Uri: uri(r),
+ URI: uri(r),
Headers: r.Header,
Cookies: make(map[string]string),
RawQuery: r.URL.RawQuery,
diff --git a/service/http/service.go b/service/http/service.go
index 7a7354fb..3d200845 100644
--- a/service/http/service.go
+++ b/service/http/service.go
@@ -27,6 +27,7 @@ type Service struct {
http *http.Server
}
+// AddMiddleware adds new net/http middleware.
func (s *Service) AddMiddleware(m middleware) {
s.mdws = append(s.mdws, m)
}
diff --git a/service/http/uploads.go b/service/http/uploads.go
index 4607dea4..9b205f00 100644
--- a/service/http/uploads.go
+++ b/service/http/uploads.go
@@ -10,23 +10,23 @@ import (
)
const (
- // There is no error, the file uploaded with success.
+ // UploadErrorOK - no error, the file uploaded with success.
UploadErrorOK = 0
- // No file was uploaded.
+ // UploadErrorNoFile - no file was uploaded.
UploadErrorNoFile = 4
- // Missing a temporary folder.
+ // UploadErrorNoTmpDir - missing a temporary folder.
UploadErrorNoTmpDir = 5
- // Failed to write file to disk.
+ // UploadErrorCantWrite - failed to write file to disk.
UploadErrorCantWrite = 6
- // Forbid file extension.
+ // UploadErrorExtension - forbidden file extension.
UploadErrorExtension = 7
)
-// tree manages uploaded files tree and temporary files.
+// Uploads tree manages uploaded files tree and temporary files.
type Uploads struct {
// associated temp directory and forbidden extensions.
cfg *UploadsConfig
@@ -99,6 +99,7 @@ func NewUpload(f *multipart.FileHeader) *FileUpload {
}
}
+// Open moves file content into temporary file available for PHP.
func (f *FileUpload) Open(cfg *UploadsConfig) error {
if cfg.Forbids(f.Name) {
f.Error = UploadErrorExtension
diff --git a/service/http/uploads_config.go b/service/http/uploads_config.go
index 148ebba3..e90d9b70 100644
--- a/service/http/uploads_config.go
+++ b/service/http/uploads_config.go
@@ -25,7 +25,7 @@ func (cfg *UploadsConfig) TmpDir() string {
return os.TempDir()
}
-// Forbid must return true if file extension is not allowed for the upload.
+// Forbids must return true if file extension is not allowed for the upload.
func (cfg *UploadsConfig) Forbids(filename string) bool {
ext := strings.ToLower(path.Ext(filename))
diff --git a/service/service.go b/service/service.go
index 6ddcda41..6cd12b51 100644
--- a/service/service.go
+++ b/service/service.go
@@ -2,7 +2,7 @@ package service
import "sync"
-// svc provides high level functionality for road runner svc.
+// Service provides high level functionality for road runner modules.
type Service interface {
// Init must return configure service and return true if service hasStatus enabled. Must return error in case of
// misconfiguration. Services must not be used without proper configuration pushed first.
diff --git a/service/static/config.go b/service/static/config.go
index d55fcd66..1020b8cd 100644
--- a/service/static/config.go
+++ b/service/static/config.go
@@ -20,7 +20,7 @@ type Config struct {
Forbid []string
}
-// Forbid must return true if file extension is not allowed for the upload.
+// Forbids must return true if file extension is not allowed for the upload.
func (cfg *Config) Forbids(filename string) bool {
ext := strings.ToLower(path.Ext(filename))