Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface IQueryContextFactory
- {
- QueryContext Create(string query, HttpRequest request);
- }
- internal class HttpRequestQueryContextFactory : IQueryContextFactory
- {
- public QueryContext Create(string query, HttpRequest request)
- {
- if (string.IsNullOrEmpty(query))
- throw new ArgumentNullException(nameof(query));
- if (request == null)
- throw new ArgumentNullException(nameof(request));
- return new QueryContext
- {
- Method = request.Method,
- QueryString = string.Concat(query, request.QueryString),
- Parameters = request.Query.ToDictionary(x => x.Key, x => x.Value.ToString().Replace(""", string.Empty)),
- Headers = request.Headers.ToDictionary(x => x.Key, x => x.Value.ToString())
- };
- }
- }
- [HttpGet]
- public IActionResult Process(string query)
- {
- (...)
- var ctx = _contextFactory.Create(query, Request);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement