41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Mindforge.API.Services.Interfaces;
|
|
|
|
namespace Mindforge.API.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("api/v1/repository")]
|
|
public class RepositoryController : ControllerBase
|
|
{
|
|
private readonly IGiteaService _giteaService;
|
|
|
|
public RepositoryController(IGiteaService giteaService)
|
|
{
|
|
_giteaService = giteaService;
|
|
}
|
|
|
|
[HttpGet("info")]
|
|
public IActionResult GetInfo()
|
|
{
|
|
return Ok(new { name = _giteaService.GetRepositoryName() });
|
|
}
|
|
|
|
[HttpGet("tree")]
|
|
public async Task<IActionResult> GetTree()
|
|
{
|
|
var tree = await _giteaService.GetFileTreeAsync();
|
|
return Ok(tree);
|
|
}
|
|
|
|
[HttpGet("file")]
|
|
public async Task<IActionResult> GetFile([FromQuery] string path)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(path))
|
|
return BadRequest(new { error = "path query parameter is required." });
|
|
|
|
var content = await _giteaService.GetFileContentAsync(path);
|
|
return Ok(new { path, content });
|
|
}
|
|
}
|
|
}
|