engine: resources: Refactor HTTP constants
This commit is contained in:
@@ -37,17 +37,21 @@ import (
|
|||||||
securefilepath "github.com/cyphar/filepath-securejoin"
|
securefilepath "github.com/cyphar/filepath-securejoin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
engine.RegisterResource("http:server", func() engine.Res { return &HTTPServerRes{} })
|
|
||||||
engine.RegisterResource("http:file", func() engine.Res { return &HTTPFileRes{} })
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// HTTPUseSecureJoin specifies that we should add in a "secure join" lib
|
// HTTPUseSecureJoin specifies that we should add in a "secure join" lib
|
||||||
// so that we avoid the ../../etc/passwd and symlink problems.
|
// so that we avoid the ../../etc/passwd and symlink problems.
|
||||||
HTTPUseSecureJoin = true
|
HTTPUseSecureJoin = true
|
||||||
|
|
||||||
|
httpKind = "http"
|
||||||
|
httpServerKind = httpKind + ":server"
|
||||||
|
httpFileKind = httpKind + ":file"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
engine.RegisterResource(httpServerKind, func() engine.Res { return &HTTPServerRes{} })
|
||||||
|
engine.RegisterResource(httpFileKind, func() engine.Res { return &HTTPFileRes{} })
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPServerRes is an http server resource. It serves files, but does not
|
// HTTPServerRes is an http server resource. It serves files, but does not
|
||||||
// actually apply any state. The name is used as the address to listen on,
|
// actually apply any state. The name is used as the address to listen on,
|
||||||
// unless the Address field is specified, and in that case it is used instead.
|
// unless the Address field is specified, and in that case it is used instead.
|
||||||
|
|||||||
Reference in New Issue
Block a user