Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
708e75b7
Commit
708e75b7
authored
Dec 19, 2018
by
Sietse Ringers
Browse files
Remove parameter from irmarequestor.HttpHandlerFunc()
parent
91166ae1
Changes
3
Show whitespace changes
Inline
Side-by-side
server/backend/api.go
View file @
708e75b7
...
...
@@ -29,17 +29,15 @@ func Initialize(configuration *server.Configuration) error {
if
conf
.
IrmaConfiguration
==
nil
{
var
err
error
var
path
,
assets
string
if
conf
.
CachePath
==
""
{
conf
.
CachePath
,
err
=
Cache
Path
()
if
err
!=
nil
{
return
err
}
conf
.
CachePath
=
filepath
.
Join
(
conf
.
CachePath
,
"irmalibrary"
)
path
=
conf
.
IrmaConfiguration
Path
assets
=
""
}
else
{
path
=
filepath
.
Join
(
conf
.
CachePath
,
"irma_configuration"
)
assets
=
conf
.
IrmaConfigurationPath
}
conf
.
IrmaConfiguration
,
err
=
irma
.
NewConfiguration
(
filepath
.
Join
(
conf
.
CachePath
,
"irma_configuration"
),
conf
.
IrmaConfigurationPath
,
)
conf
.
IrmaConfiguration
,
err
=
irma
.
NewConfiguration
(
path
,
assets
)
if
err
!=
nil
{
return
err
}
...
...
@@ -164,8 +162,9 @@ func HandleProtocolMessage(
path
=
path
[
:
len
(
path
)
-
1
]
}
}
conf
.
Logger
.
Debugf
(
"Routing protocol message: %s %s"
,
method
,
path
)
pattern
:=
regexp
.
MustCompile
(
"(
\\
w+)/?(
\\
w*)
"
)
pattern
:=
regexp
.
MustCompile
(
"(
\\
w+)/?(
|commitments|proofs|status)$
"
)
matches
:=
pattern
.
FindStringSubmatch
(
path
)
if
len
(
matches
)
!=
3
{
conf
.
Logger
.
Warnf
(
"Invalid URL: %s"
,
path
)
...
...
server/irmarequestor/main.go
View file @
708e75b7
...
...
@@ -48,15 +48,10 @@ func CancelSession(token string) error {
// with IRMA apps. Initialize() must be called before this.
//
// Example usage:
// http.HandleFunc("/irma/", irmarequestor.HttpHandlerFunc(
"/irma/"
))
// http.HandleFunc("/irma/", irmarequestor.HttpHandlerFunc())
//
// The IRMA app can then perform IRMA sessions at https://example.com/irma.
// Note that the two strings must be equal, i.e. you must pass the pattern at which
// you register the handler.
func
HttpHandlerFunc
(
pattern
string
)
http
.
HandlerFunc
{
if
len
(
pattern
)
!=
0
&&
pattern
[
0
]
!=
'/'
{
pattern
=
"/"
+
pattern
}
func
HttpHandlerFunc
()
http
.
HandlerFunc
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
var
message
[]
byte
message
,
err
:=
ioutil
.
ReadAll
(
r
.
Body
)
...
...
@@ -64,8 +59,7 @@ func HttpHandlerFunc(pattern string) http.HandlerFunc {
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
return
}
path
:=
r
.
URL
.
Path
[
len
(
pattern
)
:
]
status
,
response
,
result
:=
backend
.
HandleProtocolMessage
(
path
,
r
.
Method
,
r
.
Header
,
message
)
status
,
response
,
result
:=
backend
.
HandleProtocolMessage
(
r
.
URL
.
Path
,
r
.
Method
,
r
.
Header
,
message
)
w
.
WriteHeader
(
status
)
w
.
Write
(
response
)
if
result
!=
nil
{
...
...
server/irmaserver/server.go
View file @
708e75b7
...
...
@@ -60,7 +60,7 @@ func Handler(config *Configuration) (http.Handler, error) {
})
.
Handler
)
// Mount server for irmaclient
router
.
Mount
(
"/irma/"
,
irmarequestor
.
HttpHandlerFunc
(
"/irma/"
))
router
.
Mount
(
"/irma/"
,
irmarequestor
.
HttpHandlerFunc
())
// Server routes
router
.
Post
(
"/session"
,
handleCreate
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment