Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Breeze
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
Breeze
Commits
8b25d8f1
Commit
8b25d8f1
authored
May 23, 2017
by
Jeremy Bokobza
Committed by
GitHub
May 23, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #75 from bokobza/pre-alpha-dev-release
Added looger to log all incoming api requests
parents
e524ccbe
d50d1ecf
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
13 deletions
+62
-13
LoggingActionFilter.cs
Breeze/src/Breeze.Api/LoggingActionFilter.cs
+40
-0
Startup.cs
Breeze/src/Breeze.Api/Startup.cs
+1
-1
RequestModels.cs
Breeze/src/Breeze.Wallet/Models/RequestModels.cs
+18
-10
WalletFeature.cs
Breeze/src/Breeze.Wallet/WalletFeature.cs
+3
-2
No files found.
Breeze/src/Breeze.Api/LoggingActionFilter.cs
0 → 100644
View file @
8b25d8f1
using
System
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Http.Extensions
;
using
Microsoft.AspNetCore.Mvc.Filters
;
using
Microsoft.Extensions.Logging
;
namespace
Breeze.Api
{
/// <summary>
/// An asynchronous action filter whose role is to log details from the Http requests to the API.
/// </summary>
/// <seealso cref="Microsoft.AspNetCore.Mvc.Filters.IAsyncActionFilter" />
public
class
LoggingActionFilter
:
IAsyncActionFilter
{
private
readonly
ILogger
logger
;
public
LoggingActionFilter
(
ILoggerFactory
loggerFactory
)
{
this
.
logger
=
loggerFactory
.
CreateLogger
(
"api.request.logger"
);
}
public
async
Task
OnActionExecutionAsync
(
ActionExecutingContext
context
,
ActionExecutionDelegate
next
)
{
HttpRequest
request
=
context
.
HttpContext
.
Request
;
// get the body
var
body
=
string
.
Empty
;
var
arguments
=
context
.
ActionArguments
;
if
(
request
.
ContentLength
!=
null
&&
arguments
!=
null
&&
arguments
.
Any
())
{
body
=
string
.
Join
(
Environment
.
NewLine
,
arguments
.
Values
);
}
this
.
logger
.
LogDebug
(
$"Received
{
request
.
Method
}
{
request
.
GetDisplayUrl
()}
. Body: '
{
body
}
'"
);
await
next
();
}
}
}
Breeze/src/Breeze.Api/Startup.cs
View file @
8b25d8f1
...
...
@@ -51,7 +51,7 @@ namespace Breeze.Api
});
// Add framework services.
services
.
AddMvc
()
services
.
AddMvc
(
options
=>
options
.
Filters
.
Add
(
typeof
(
LoggingActionFilter
))
)
// add serializers for NBitcoin objects
.
AddJsonOptions
(
options
=>
NBitcoin
.
JsonConverters
.
Serializer
.
RegisterFrontConverters
(
options
.
SerializerSettings
))
.
AddControllers
(
services
);
...
...
Breeze/src/Breeze.Wallet/Models/RequestModels.cs
View file @
8b25d8f1
...
...
@@ -7,10 +7,18 @@ using Newtonsoft.Json.Converters;
namespace
Breeze.Wallet.Models
{
public
class
RequestModel
{
public
override
string
ToString
()
{
return
JsonConvert
.
SerializeObject
(
this
,
Formatting
.
Indented
);
}
}
/// <summary>
/// Object used to create a new wallet
/// </summary>
public
class
WalletCreationRequest
public
class
WalletCreationRequest
:
RequestModel
{
[
Required
(
ErrorMessage
=
"A password is required."
)]
public
string
Password
{
get
;
set
;
}
...
...
@@ -23,7 +31,7 @@ namespace Breeze.Wallet.Models
public
string
Name
{
get
;
set
;
}
}
public
class
WalletLoadRequest
public
class
WalletLoadRequest
:
RequestModel
{
[
Required
(
ErrorMessage
=
"A password is required."
)]
public
string
Password
{
get
;
set
;
}
...
...
@@ -34,7 +42,7 @@ namespace Breeze.Wallet.Models
public
string
Name
{
get
;
set
;
}
}
public
class
WalletRecoveryRequest
public
class
WalletRecoveryRequest
:
RequestModel
{
[
Required
(
ErrorMessage
=
"A mnemonic is required."
)]
public
string
Mnemonic
{
get
;
set
;
}
...
...
@@ -53,7 +61,7 @@ namespace Breeze.Wallet.Models
public
DateTime
CreationDate
{
get
;
set
;
}
}
public
class
WalletHistoryRequest
public
class
WalletHistoryRequest
:
RequestModel
{
[
Required
(
ErrorMessage
=
"The name of the wallet is missing."
)]
public
string
WalletName
{
get
;
set
;
}
...
...
@@ -62,7 +70,7 @@ namespace Breeze.Wallet.Models
public
CoinType
CoinType
{
get
;
set
;
}
}
public
class
WalletBalanceRequest
public
class
WalletBalanceRequest
:
RequestModel
{
[
Required
(
ErrorMessage
=
"The name of the wallet is missing."
)]
public
string
WalletName
{
get
;
set
;
}
...
...
@@ -71,13 +79,13 @@ namespace Breeze.Wallet.Models
public
CoinType
CoinType
{
get
;
set
;
}
}
public
class
WalletName
public
class
WalletName
:
RequestModel
{
[
Required
(
ErrorMessage
=
"The name of the wallet is missing."
)]
public
string
Name
{
get
;
set
;
}
}
public
class
BuildTransactionRequest
public
class
BuildTransactionRequest
:
RequestModel
{
[
Required
(
ErrorMessage
=
"The name of the wallet is missing."
)]
public
string
WalletName
{
get
;
set
;
}
...
...
@@ -103,13 +111,13 @@ namespace Breeze.Wallet.Models
public
bool
AllowUnconfirmed
{
get
;
set
;
}
}
public
class
SendTransactionRequest
public
class
SendTransactionRequest
:
RequestModel
{
[
Required
(
ErrorMessage
=
"A transaction in hexadecimal format is required."
)]
public
string
Hex
{
get
;
set
;
}
}
public
class
GetUnusedAddressModel
public
class
GetUnusedAddressModel
:
RequestModel
{
/// <summary>
/// The name of the wallet from which to get the address.
...
...
@@ -130,7 +138,7 @@ namespace Breeze.Wallet.Models
public
string
AccountName
{
get
;
set
;
}
}
public
class
GetUnusedAccountModel
public
class
GetUnusedAccountModel
:
RequestModel
{
/// <summary>
/// The name of the wallet in which to create the account.
...
...
Breeze/src/Breeze.Wallet/WalletFeature.cs
View file @
8b25d8f1
using
Stratis.Bitcoin.Builder.Feature
;
using
Breeze.Wallet.Controllers
;
using
Microsoft.Extensions.DependencyInjection
;
using
NBitcoin
;
using
Stratis.Bitcoin
;
using
Stratis.Bitcoin.Builder
;
using
Stratis.Bitcoin.Logging
;
using
Microsoft.Extensions.Logging
;
namespace
Breeze.Wallet
{
...
...
@@ -41,6 +41,7 @@ namespace Breeze.Wallet
.
FeatureServices
(
services
=>
{
services
.
AddSingleton
<
ITracker
,
Tracker
>();
services
.
AddSingleton
<
ILoggerFactory
>(
Logs
.
LoggerFactory
);
services
.
AddSingleton
<
IWalletManager
,
WalletManager
>();
services
.
AddSingleton
<
WalletController
>();
});
...
...
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