Commit 5444ffaa authored by Juergen Enge's avatar Juergen Enge
Browse files

enhanced documentation

parent 33782da6
Pipeline #13847 passed with stages
in 3 minutes and 51 seconds
.idea
bin/
*.jp2
*.toml
......@@ -21,14 +21,69 @@ MariaDB/MySQL Server with table structure of [table.sql](tables.sql)
go build gitlab.switch.ch/memoriav/memobase-2020/sevices/streaming-server/cmd/tokenService
## Usage
http://localhost:83/memostream/sig-01
## Server Commands
http://localhost:83/[audience]/[subject]
### clearcache
https://media.memobase.k8s.unibas.ch/command/clearcache?token=XXX
Token Subject: ```cmd:clearcache```
Clears the internal media cache of the server.
should be done after changeing database contents.
### media query
https://media.memobase.k8s.unibas.ch/memo/<signature>/<command>
Token Subject: ```<signature>```
* master
Delivers the mediaserver's master object without any transformation.
Mainly used for audio and video objects.
https://media.memobase.k8s.unibas.ch/command/clearcache?token=XXX
sub: cmd:clearcache
* resize
Default command for image retrieval. Needs obligatory size parameter.
http://localhost:88/memo/sig-5005/resize/size800x200/stretch/formatJPEG
* iiif
sends parameters directly to iiif image server
http://localhost:88/memo/sig-5005/iiif/full/800,200/0/default.jpg
http://localhost:88/memo/sig-5005/iiif/info.json
## Syntax
###Notational Conventions and Generic Grammar
Grammar is based on the Grammar used in RFC1616
https://tools.ietf.org/html/rfc2616#page-14
~~~~
memo_Url = serverBase "/" (dataReqest | serverCommand)
serverCommand = "command" "/" (clearcache) token
clearcache = "clearcache"
dataRequest = data-Base "/" signature "/" media-Command [token]
data-Base = TEXT
signature = TEXT
media-Command = master | resize | iiif
master = "master"
resize = "resize" "/" size ["/" (stretch | crop)] ["/" flip] ["/" format]
size = "size" width "x" height
width = 1*DIGIT
height = 1*DIGIT
stretch = "stretch"
crop = "crop"
flip = "flip"
format = "format" ("PNG" ¦ "JPEG")
iiif = "iiif" "/" (iiif-ImageRequest | iiif-InformationRequest)
iiif-InformationRequest = "info.json"
iiif-ImageRequest = iiifregion "/" iiifsize "/" iiifrotation "/" iiifquality "." iiifformat
; please refer to iiif api - https://iiif.io/api/image/2.0/#uri-syntax
token = "?token=" HEX
~~~~
### Docker
......
......@@ -74,9 +74,11 @@ func LoadConfig(filepath string) Config {
dsn := os.Getenv("DSN")
if dsn != "" {
conf.ResolverDBMySQL.Dsn = dsn
log.Printf("DSN from Environment: [%s]", conf.ResolverDBMySQL.Dsn)
// removed because of security issues with password in logfile
//log.Printf("DSN from Environment: [%s]", conf.ResolverDBMySQL.Dsn)
} else {
log.Printf("DSN from Config: [%s]", conf.ResolverDBMySQL.Dsn)
// removed because of security issues with password in logfile
//log.Printf("DSN from Config: [%s]", conf.ResolverDBMySQL.Dsn)
}
return conf
......
logfile = "" # log file location
loglevel = "DEBUG" # CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG
accesslog = "" # http access log file
addr = "localhost:88"
certpem = "" # tls client certificate file in PEM format
keypem = "" # tls client key file in PEM format
staticdir = "C:/daten/go/dev/memobase/streaming-server/web/static/"
staticprefix = "/static/"
urlprefix = "/memo/" # prefix for accessing signature based content
# http://localhost:81/command/clearcache?auth=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJjbWQ6Y2xlYXJjYWNoZSIsImV4cCI6MTgxNjIzOTAyMn0.M_Y6R4yMAFEyo534-SXAffPwdHv929WcuSgQUcjiz10
cmdprefix = "/command/"
jwtkey = "swordfish"
jwtalg = ["HS256", "HS384", "HS512"] # "hs256" "hs384" "hs512" "es256" "es384" "es512" "ps256" "ps384" "ps512"
resolverCacheSize = 1000
errorTemplate = "C:/daten/go/dev/memobase/streaming-server/web/template/error.gohtml" # error message for memoHandler
videoviewertemplate = "C:/daten/go/dev/memobase/streaming-server/web/template/videojs.gohtml"
audioviewertemplate = "C:/daten/go/dev/memobase/streaming-server/web/template/audiohowler.gohtml"
baseurl = "http://localhost:88"
[[filemap]]
alias = "c"
folder = "C:/"
[[filemap]]
alias = "blah"
folder = "C:/temp"
[[filemap]]
alias = "demo"
folder = "C:/daten/go/src/gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/web/static"
[iiif]
prefix = "/iiif/"
base = "C:/daten/go/src/gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server/web/static/"
url = "http://localhost:8182/iiif/2/"
jwtsubprefix = "iiif:"
viewertemplate = "C:/daten/go/dev/memobase/streaming-server/web/template/openseadragon.gohtml"
[resolverDBMySQL]
#if dsn is empty, the static resolver will be used
#[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...&paramN=valueN]
dsn = "test:[swordfish]@tcp(localhost:3306)/test"
# should be smaller than server connection timeout to allow controlled reconnect
connMaxTimeout = "4h"
# query has to return the fields uri, access and protocol. One parameter
#query = "SELECT uri, access, proto AS protocol, `status` FROM mediaserver.entities WHERE sig = ?"
query = "SELECT `uri`, `access`, `proto` AS protocol, `status`, `type`, `mimetype`, `width`, `height`, `duration` FROM test.entities_metadata WHERE sig = ?"
schema = "test"
......@@ -48,6 +48,13 @@ func (iai *ActionImageIIIF) iiif(w http.ResponseWriter, req *http.Request, me *M
if !iai.ms.fspool.Exist(me.URI) {
return false, fmt.Errorf("file not found: %v", me.URI)
}
// check for strange params like ".."
for _, p := range params {
if strings.Trim(p, ". ") == "" {
return false, fmt.Errorf("invalid parameter %s", p)
}
}
if err := iai.ms.proxyIIIF(req, w, me.Signature, filepath.ToSlash(iai.ms.fspool.Truename(me.URI)), strings.Join(params, "/"), me.Access == Media_Public); err != nil {
return false, fmt.Errorf("cannot proxy to iiif server: %v", err)
}
......@@ -139,7 +146,7 @@ func (iai *ActionImageIIIF) resize(w http.ResponseWriter, req *http.Request, me
rotate = rot[0]
}
if _, ok := ps["flip"]; !ok {
if _, ok := ps["flip"]; ok {
rotate = "!" + rotate
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment