working commit
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
filepathRegexp = `{path:[a-zA-Z_][\-a-zA-Z0-9_\/\.%~]+}`
|
||||
fileApiPrefix = `/v3/file`
|
||||
|
||||
FileExistsPath = fmt.Sprintf("%s/%s", fileApiPrefix, filepathRegexp)
|
||||
|
||||
ServiceHelloPath = "/service/hello"
|
||||
)
|
||||
+11
-2
@@ -43,8 +43,17 @@ func (svc *Service) Build() error {
|
||||
svc.logg.Infof("Service build ")
|
||||
|
||||
svc.rout = router.NewRouter()
|
||||
svc.rout.Get(ServiceHelloPath, svc.hand.SendHello)
|
||||
svc.rout.Get(FileExistsPath, svc.hand.FileExists)
|
||||
svc.rout.Get("/v3/api/service/hello", svc.hand.SendHello)
|
||||
|
||||
svc.rout.Head("/v3/api/file/{filepath}", svc.hand.FileExists)
|
||||
svc.rout.Put("/v3/api/file/{filepath}", svc.hand.PutFile)
|
||||
svc.rout.Get("/v3/api/file/{filepath}", svc.hand.GetFile)
|
||||
svc.rout.Delete("/v3/api/file/{filepath}", svc.hand.DeleteFile)
|
||||
|
||||
selector := svc.rout.Selector()
|
||||
for _, item := range selector.Routes {
|
||||
svc.logg.Infof("%s\t%s", item.Method, item.RawPath)
|
||||
}
|
||||
|
||||
listenAddress := fmt.Sprintf("%s:%d", svc.address, svc.portnum)
|
||||
svc.listen, err = net.Listen(protocol, listenAddress)
|
||||
|
||||
Reference in New Issue
Block a user