...

Source file src/go.formulabun.club/replays/staff/server/go/api_default_service.go

Documentation: go.formulabun.club/replays/staff/server/go

     1  /*
     2   * GoBun replay download
     3   *
     4   * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
     5   *
     6   * API version: 0.0.1
     7   * Generated by: OpenAPI Generator (https://openapi-generator.tech)
     8   */
     9  
    10  package openapi
    11  
    12  import (
    13  	"bytes"
    14  	"context"
    15  	"errors"
    16  	"io"
    17  	"net/http"
    18  	"os"
    19  	"path"
    20  
    21  	"go.formulabun.club/srb2kart/lump/replay"
    22  )
    23  
    24  // DefaultApiService is a service that implements the logic for the DefaultApiServicer
    25  // This service should implement the business logic for every endpoint for the DefaultApi API.
    26  // Include any external packages or services that will be required by this service.
    27  type DefaultApiService struct {
    28  }
    29  
    30  // NewDefaultApiService creates a default api service
    31  func NewDefaultApiService() DefaultApiServicer {
    32  	return &DefaultApiService{}
    33  }
    34  
    35  // ReplayIdGet - Get a replay
    36  func (s *DefaultApiService) ReplayIdGet(ctx context.Context, id string) (ImplResponse, error) {
    37  	filePath := path.Join("/data", id)
    38  	file, err := os.Open(filePath)
    39  	if err != nil {
    40  		return Response(http.StatusNotFound, nil, "temp.lmp"), err
    41  	}
    42  
    43  	replay, err := replay.ReadReplay(file)
    44  	if err != nil {
    45  		return Response(http.StatusInternalServerError, nil, ""), err
    46  	}
    47  	fileName := replay.GetGuestFileName()
    48  
    49  	var headerBuffer bytes.Buffer
    50  	err = replay.Write(&headerBuffer)
    51  	if err != nil {
    52  		return Response(http.StatusInternalServerError, nil, ""), err
    53  	}
    54  
    55  	fileData := io.MultiReader(&headerBuffer, file)
    56  	return Response(http.StatusOK, fileData, fileName), err
    57  }
    58  
    59  // StaffGet - Get a replay as staff
    60  func (s *DefaultApiService) StaffGet(ctx context.Context, ids []string) (ImplResponse, error) {
    61  	// TODO - update StaffGet with the required logic for this service method.
    62  	// Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
    63  
    64  	//TODO: Uncomment the next line to return response Response(200, *os.File{}) or use other options such as http.Ok ...
    65  	//return Response(200, *os.File{}), nil
    66  
    67  	//TODO: Uncomment the next line to return response Response(204, {}) or use other options such as http.Ok ...
    68  	//return Response(204, nil),nil
    69  
    70  	//TODO: Uncomment the next line to return response Response(206, *os.File{}) or use other options such as http.Ok ...
    71  	//return Response(206, *os.File{}), nil
    72  
    73  	return Response(http.StatusNotImplemented, nil, ""), errors.New("StaffGet method not implemented")
    74  }
    75  

View as plain text