Merge pull request 'refactor: migrated to Response.body' (#229) from Chewing_Bever/vieter:dev into dev
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
ci/woodpecker/push/arch Pipeline was successful Details
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/man Pipeline was successful Details
ci/woodpecker/push/test Pipeline was successful Details
ci/woodpecker/push/docker Pipeline was successful Details
ci/woodpecker/push/deploy Pipeline was successful Details

Reviewed-on: vieter/vieter#229
pull/234/head
Jef Roosens 2022-06-05 22:47:21 +02:00
commit 5df5850044
2 changed files with 6 additions and 6 deletions

View File

@ -66,5 +66,5 @@ fn (c &Client) send_request_with_body<T>(method Method, url string, params map[s
fn (c &Client) send_request_raw_response(method Method, url string, params map[string]string, body string) ?string { fn (c &Client) send_request_raw_response(method Method, url string, params map[string]string, body string) ?string {
res := c.send_request_raw(method, url, params, body)? res := c.send_request_raw(method, url, params, body)?
return res.text return res.body
} }

View File

@ -25,12 +25,12 @@ pub const (
http_302 = http.new_response( http_302 = http.new_response(
status: .found status: .found
text: '302 Found' body: '302 Found'
header: headers_close header: headers_close
) )
http_400 = http.new_response( http_400 = http.new_response(
status: .bad_request status: .bad_request
text: '400 Bad Request' body: '400 Bad Request'
header: http.new_header( header: http.new_header(
key: .content_type key: .content_type
value: 'text/plain' value: 'text/plain'
@ -38,7 +38,7 @@ pub const (
) )
http_404 = http.new_response( http_404 = http.new_response(
status: .not_found status: .not_found
text: '404 Not Found' body: '404 Not Found'
header: http.new_header( header: http.new_header(
key: .content_type key: .content_type
value: 'text/plain' value: 'text/plain'
@ -46,7 +46,7 @@ pub const (
) )
http_500 = http.new_response( http_500 = http.new_response(
status: .internal_server_error status: .internal_server_error
text: '500 Internal Server Error' body: '500 Internal Server Error'
header: http.new_header( header: http.new_header(
key: .content_type key: .content_type
value: 'text/plain' value: 'text/plain'
@ -209,7 +209,7 @@ pub fn (mut ctx Context) send_response_to_client(mimetype string, res string) bo
mut resp := http.Response{ mut resp := http.Response{
header: header.join(web.headers_close) header: header.join(web.headers_close)
text: res body: res
} }
resp.set_version(.v1_1) resp.set_version(.v1_1)
resp.set_status(ctx.status) resp.set_status(ctx.status)