Poszukiwacz/Serwer/Serwer.Api/Controllers/SearchController.cs

31 lines
806 B
C#
Raw Normal View History

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Serwer.Infrastructure.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Serwer.Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class SearchController : ControllerBase
{
private readonly ISearchService _searchService;
public SearchController(ISearchService searchService)
{
_searchService = searchService;
}
[Authorize]
[HttpGet("{query}")]
public async Task<IActionResult> Search(string query)
{
var results = await _searchService.Search(query);
return Ok(results);
}
}
}