58 lines
1.6 KiB
Go
58 lines
1.6 KiB
Go
/*
|
|
MastoGem, A Mastodon proxy for Gemini
|
|
Copyright (C) 2021 Romain de Laage
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
package main
|
|
|
|
import "log"
|
|
|
|
type Blog struct {
|
|
Id string `json:"id"`
|
|
Content string `json:"content"`
|
|
Date string `json:"created_at"`
|
|
Author Account `json:"account"`
|
|
}
|
|
|
|
type Config struct {
|
|
Listen string `json:"listen"`
|
|
CertPath string `json:"cert_path"`
|
|
KeyPath string `json:"key_path"`
|
|
BaseURL string `json:"base_url"`
|
|
Title string `json:"title"`
|
|
HomeMessage string `json:"home_message"`
|
|
}
|
|
|
|
type Account struct {
|
|
Id string `json:"id"`
|
|
Name string `json:"display_name"`
|
|
Url string `json:"url"`
|
|
}
|
|
|
|
type Thread struct {
|
|
Ancestors []Blog `json:"ancestors"`
|
|
Descendants []Blog `json:"descendants"`
|
|
}
|
|
|
|
func main() {
|
|
config := getConfig()
|
|
|
|
listener := listen(config.Listen, config.CertPath, config.KeyPath)
|
|
log.Println("Server successfully started")
|
|
log.Println("Server is listening at " + config.Listen)
|
|
|
|
serve(listener, config.BaseURL, config.Title, config.HomeMessage)
|
|
}
|