GitRoot

Craft your forge, Build your project, Grow your community freely
 1// SPDX-FileCopyrightText: 2026 Romain Maneschi <romain@gitroot.dev>
 2//
 3// SPDX-License-Identifier: MIT
 4
 5package model
 6
 7import "github.com/tidwall/gjson"
 8
 9type HttpRequest struct {
10	Method string              `json:"method"`
11	Url    string              `json:"url"`
12	Body   string              `json:"body"`
13	Header map[string][]string `json:"header"`
14}
15
16type HttpResponse struct {
17	StatusCode int    `json:"statusCode"`
18	Body       string `json:"body"`
19}
20
21func HttpResponseFromString(res string) HttpResponse {
22	jsonRes := gjson.Parse(res)
23	return HttpResponse{
24		StatusCode: int(jsonRes.Get("statusCode").Int()),
25		Body:       jsonRes.Get("body").String(),
26	}
27}