@@ -31,7 +31,7 @@ pub enum ChhotoError {
3131
3232// Define JSON struct for returning success/error data
3333#[ derive( Serialize ) ]
34- struct Response {
34+ struct JSONResponse {
3535 success : bool ,
3636 error : bool ,
3737 reason : String ,
@@ -115,15 +115,15 @@ pub async fn add_link(
115115 HttpResponse :: Created ( ) . json ( response)
116116 }
117117 Err ( ServerError ) => {
118- let response = Response {
118+ let response = JSONResponse {
119119 success : false ,
120120 error : true ,
121121 reason : "Something went wrong when adding the link." . to_string ( ) ,
122122 } ;
123123 HttpResponse :: InternalServerError ( ) . json ( response)
124124 }
125125 Err ( ClientError { reason } ) => {
126- let response = Response {
126+ let response = JSONResponse {
127127 success : false ,
128128 error : true ,
129129 reason,
@@ -192,15 +192,15 @@ pub async fn expand(req: String, data: web::Data<AppState>, http: HttpRequest) -
192192 HttpResponse :: Ok ( ) . json ( body)
193193 }
194194 Err ( ServerError ) => {
195- let body = Response {
195+ let body = JSONResponse {
196196 success : false ,
197197 error : true ,
198198 reason : "Something went wrong when finding the link." . to_string ( ) ,
199199 } ;
200200 HttpResponse :: BadRequest ( ) . json ( body)
201201 }
202202 Err ( ClientError { reason } ) => {
203- let body = Response {
203+ let body = JSONResponse {
204204 success : false ,
205205 error : true ,
206206 reason,
@@ -226,23 +226,23 @@ pub async fn edit_link(
226226 if result. success || is_session_valid ( session, config) {
227227 match utils:: edit_link ( & req, & data. db , config) {
228228 Ok ( ( ) ) => {
229- let body = Response {
229+ let body = JSONResponse {
230230 success : true ,
231231 error : false ,
232232 reason : String :: from ( "Edit was successful." ) ,
233233 } ;
234234 HttpResponse :: Created ( ) . json ( body)
235235 }
236236 Err ( ServerError ) => {
237- let body = Response {
237+ let body = JSONResponse {
238238 success : false ,
239239 error : true ,
240240 reason : "Something went wrong when editing the link." . to_string ( ) ,
241241 } ;
242242 HttpResponse :: InternalServerError ( ) . json ( body)
243243 }
244244 Err ( ClientError { reason } ) => {
245- let body = Response {
245+ let body = JSONResponse {
246246 success : false ,
247247 error : true ,
248248 reason,
@@ -377,7 +377,7 @@ pub async fn login(req: String, session: Session, data: web::Data<AppState>) ->
377377 if let Some ( valid_pass) = authorized {
378378 if !valid_pass {
379379 warn ! ( "Failed login attempt!" ) ;
380- let response = Response {
380+ let response = JSONResponse {
381381 success : false ,
382382 error : true ,
383383 reason : "Wrong password!" . to_string ( ) ,
@@ -390,7 +390,7 @@ pub async fn login(req: String, session: Session, data: web::Data<AppState>) ->
390390 . insert ( "chhoto-url-auth" , auth:: gen_token ( ) )
391391 . expect ( "Error inserting auth token." ) ;
392392
393- let response = Response {
393+ let response = JSONResponse {
394394 success : true ,
395395 error : false ,
396396 reason : "Correct password!" . to_string ( ) ,
@@ -442,23 +442,23 @@ pub async fn delete_link(
442442 if result. success {
443443 match utils:: delete_link ( & shortlink, & data. db , data. config . allow_capital_letters ) {
444444 Ok ( ( ) ) => {
445- let response = Response {
445+ let response = JSONResponse {
446446 success : true ,
447447 error : false ,
448448 reason : format ! ( "Deleted {shortlink}" ) ,
449449 } ;
450450 HttpResponse :: Ok ( ) . json ( response)
451451 }
452452 Err ( ServerError ) => {
453- let response = Response {
453+ let response = JSONResponse {
454454 success : false ,
455455 error : true ,
456456 reason : "Something went wrong when deleting the link." . to_string ( ) ,
457457 } ;
458458 HttpResponse :: InternalServerError ( ) . json ( response)
459459 }
460460 Err ( ClientError { reason } ) => {
461- let response = Response {
461+ let response = JSONResponse {
462462 success : false ,
463463 error : true ,
464464 reason,
0 commit comments