mirror of
https://github.com/shadoll/redmine-mcp.git
synced 2026-08-28 11:33:28 +00:00
refactor, add modularity
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import json
|
||||
import httpx
|
||||
from .config import REDMINE_URL, REDMINE_API_KEY
|
||||
|
||||
|
||||
def _headers() -> dict:
|
||||
return {
|
||||
"X-Redmine-API-Key": REDMINE_API_KEY,
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
|
||||
def _get(path: str, params: dict | None = None) -> dict:
|
||||
url = f"{REDMINE_URL}{path}"
|
||||
with httpx.Client(timeout=15) as client:
|
||||
resp = client.get(url, headers=_headers(), params=params or {})
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
|
||||
|
||||
def _put(path: str, body: dict) -> dict:
|
||||
url = f"{REDMINE_URL}{path}"
|
||||
with httpx.Client(timeout=15) as client:
|
||||
resp = client.put(url, headers=_headers(), content=json.dumps(body))
|
||||
resp.raise_for_status()
|
||||
return resp.json() if resp.content else {}
|
||||
Reference in New Issue
Block a user