refactor: moved response module to web.response
This commit is contained in:
parent
cc5df95a1a
commit
e23635a1d3
9 changed files with 9 additions and 16 deletions
34
src/web/response/response.v
Normal file
34
src/web/response/response.v
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
module response
|
||||
|
||||
pub struct Response<T> {
|
||||
pub:
|
||||
message string
|
||||
data T
|
||||
}
|
||||
|
||||
// new_response constructs a new Response<String> object with the given message
|
||||
// & an empty data field.
|
||||
pub fn new_response(message string) Response<string> {
|
||||
return Response<string>{
|
||||
message: message
|
||||
data: ''
|
||||
}
|
||||
}
|
||||
|
||||
// new_data_response<T> constructs a new Response<T> object with the given data
|
||||
// & an empty message field.
|
||||
pub fn new_data_response<T>(data T) Response<T> {
|
||||
return Response<T>{
|
||||
message: ''
|
||||
data: data
|
||||
}
|
||||
}
|
||||
|
||||
// new_full_response<T> constructs a new Response<T> object with the given
|
||||
// message & data.
|
||||
pub fn new_full_response<T>(message string, data T) Response<T> {
|
||||
return Response<T>{
|
||||
message: message
|
||||
data: data
|
||||
}
|
||||
}
|
||||
Reference in a new issue