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 {
...
@@ -29,17 +29,15 @@ func Initialize(configuration *server.Configuration) error {
if
conf
.
IrmaConfiguration
==
nil
{
if
conf
.
IrmaConfiguration
==
nil
{
var
err
error
var
err
error
var
path
,
assets
string
if
conf
.
CachePath
==
""
{
if
conf
.
CachePath
==
""
{
conf
.
CachePath
,
err
=
Cache
Path
()
path
=
conf
.
IrmaConfiguration
Path
if
err
!=
nil
{
assets
=
""
return
err
}
else
{
}
path
=
filepath
.
Join
(
conf
.
CachePath
,
"irma_configuration"
)
conf
.
CachePath
=
filepath
.
Join
(
conf
.
CachePath
,
"irmalibrary"
)
assets
=
conf
.
IrmaConfigurationPath
}
}
conf
.
IrmaConfiguration
,
err
=
irma
.
NewConfiguration
(
conf
.
IrmaConfiguration
,
err
=
irma
.
NewConfiguration
(
path
,
assets
)
filepath
.
Join
(
conf
.
CachePath
,
"irma_configuration"
),
conf
.
IrmaConfigurationPath
,
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -164,8 +162,9 @@ func HandleProtocolMessage(
...
@@ -164,8 +162,9 @@ func HandleProtocolMessage(
path
=
path
[
:
len
(
path
)
-
1
]
path
=
path
[
:
len
(
path
)
-
1
]
}
}
}
}
conf
.
Logger
.
Debugf
(
"Routing protocol message: %s %s"
,
method
,
path
)
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
)
matches
:=
pattern
.
FindStringSubmatch
(
path
)
if
len
(
matches
)
!=
3
{
if
len
(
matches
)
!=
3
{
conf
.
Logger
.
Warnf
(
"Invalid URL: %s"
,
path
)
conf
.
Logger
.
Warnf
(
"Invalid URL: %s"
,
path
)
...
...
server/irmarequestor/main.go
View file @
708e75b7
...
@@ -48,15 +48,10 @@ func CancelSession(token string) error {
...
@@ -48,15 +48,10 @@ func CancelSession(token string) error {
// with IRMA apps. Initialize() must be called before this.
// with IRMA apps. Initialize() must be called before this.
//
//
// Example usage:
// 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.
// 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
func
HttpHandlerFunc
()
http
.
HandlerFunc
{
// you register the handler.
func
HttpHandlerFunc
(
pattern
string
)
http
.
HandlerFunc
{
if
len
(
pattern
)
!=
0
&&
pattern
[
0
]
!=
'/'
{
pattern
=
"/"
+
pattern
}
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
var
message
[]
byte
var
message
[]
byte
message
,
err
:=
ioutil
.
ReadAll
(
r
.
Body
)
message
,
err
:=
ioutil
.
ReadAll
(
r
.
Body
)
...
@@ -64,8 +59,7 @@ func HttpHandlerFunc(pattern string) http.HandlerFunc {
...
@@ -64,8 +59,7 @@ func HttpHandlerFunc(pattern string) http.HandlerFunc {
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
return
return
}
}
path
:=
r
.
URL
.
Path
[
len
(
pattern
)
:
]
status
,
response
,
result
:=
backend
.
HandleProtocolMessage
(
r
.
URL
.
Path
,
r
.
Method
,
r
.
Header
,
message
)
status
,
response
,
result
:=
backend
.
HandleProtocolMessage
(
path
,
r
.
Method
,
r
.
Header
,
message
)
w
.
WriteHeader
(
status
)
w
.
WriteHeader
(
status
)
w
.
Write
(
response
)
w
.
Write
(
response
)
if
result
!=
nil
{
if
result
!=
nil
{
...
...
server/irmaserver/server.go
View file @
708e75b7
...
@@ -60,7 +60,7 @@ func Handler(config *Configuration) (http.Handler, error) {
...
@@ -60,7 +60,7 @@ func Handler(config *Configuration) (http.Handler, error) {
})
.
Handler
)
})
.
Handler
)
// Mount server for irmaclient
// Mount server for irmaclient
router
.
Mount
(
"/irma/"
,
irmarequestor
.
HttpHandlerFunc
(
"/irma/"
))
router
.
Mount
(
"/irma/"
,
irmarequestor
.
HttpHandlerFunc
())
// Server routes
// Server routes
router
.
Post
(
"/session"
,
handleCreate
)
router
.
Post
(
"/session"
,
handleCreate
)
...
...
Write
Preview
Supports
Markdown
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