-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from far-galaxy/new-ics
Добавлено: .ics с синхронизацией
- Loading branch information
Showing
14 changed files
with
265 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package site | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"os" | ||
"strings" | ||
) | ||
|
||
func GetICS(w http.ResponseWriter, r *http.Request) { | ||
path := strings.TrimLeft(r.URL.Path, "/") // Удаление первого слэша | ||
|
||
filePath := fmt.Sprintf("./shedules/ics/%s", path) | ||
|
||
if _, err := os.Stat(filePath); os.IsNotExist(err) { | ||
http.Error(w, "Файл не найден", http.StatusNotFound) | ||
|
||
return | ||
} | ||
|
||
fileContent, err := os.ReadFile(filePath) | ||
if err != nil { | ||
http.Error(w, "Ошибка чтения файла", http.StatusInternalServerError) | ||
|
||
return | ||
} | ||
|
||
w.Header().Set("Content-Type", "text/calendar; charset=utf-8") | ||
w.Header().Set( | ||
"Content-Disposition", | ||
fmt.Sprintf("attachment; filename=\"%s\"", path), | ||
) | ||
|
||
// Отправка содержимого файла в ответе | ||
if _, err := w.Write(fileContent); err != nil { | ||
http.Error(w, "", http.StatusInternalServerError) | ||
|
||
return | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.