about summary refs log tree commit diff stats
path: root/src/event/server_events.c
Commit message (Expand)AuthorAgeFilesLines
...
| * Only print room history for new messages upon reconnectMichael Vetter2019-06-051-1/+31
* | Rejoin all MUCs on reconnectMichael Vetter2019-06-101-5/+3
|/
* Create seperate function for disconnect cleanupMichael Vetter2019-05-191-13/+2
* Fix ifdef guard (should have been OMEMO)Michael Vetter2019-05-061-1/+1
* Reset things on connection lossMichael Vetter2019-05-061-0/+5
* Merge pull request #1063 from paulfariello/hotfix/presence-before-rosterMichael Vetter2019-04-171-0/+1
|\
| * Handle presence received before rosterPaul Fariello2019-04-171-0/+1
* | Follow OMEMO policy even when opening window on message and carbon receptionPaul Fariello2019-04-171-0/+14
|/
* Try to start sessions with every jid in rosterPaul Fariello2019-04-101-0/+4
* Wait for discovery end to publish omemo devicelist and bundlePaul Fariello2019-04-101-0/+8
* Rework MUC reflected message filteringPaul Fariello2019-04-101-7/+3
* Ensure encrypted carbon of own message are marked as encryptedPaul Fariello2019-04-101-2/+38
* Log and print outgoing encrypted messagePaul Fariello2019-04-101-11/+55
* Handle decrypted OMEMO messages as suchPaul Fariello2019-04-101-4/+90
* Add support for encrypted carbonPaul Fariello2019-04-101-1/+1
* Add OMEMO identity materials long term storagePaul Fariello2019-04-101-0/+8
* Follow normal workflow for OMEMO message receptionPaul Fariello2019-04-101-1/+1
* Redraw screen after entry of PGP secret keyMichael Vetter2019-02-201-0/+10
* Update copyright to include 2019Michael Vetter2019-01-221-1/+1
* Merge pull request #926 from msantos/null-pointer-dereferenceMichael Vetter2018-07-301-6/+8
|\
| * server_events: fix potential NULL pointer derefMichael Santos2017-04-121-6/+8
* | Add preferences for tab displayJames Booth2018-03-091-2/+2
* | Show name in statusbar tabs WIPJames Booth2018-03-081-2/+2
* | Add /rooms service autocompletionJames Booth2018-02-051-0/+7
* | Update copyrightJames Booth2018-01-211-1/+1
|/
* Update CopyrightJames Booth2017-01-281-1/+1
* Remove status from cl_ev_presence_sendJames Booth2017-01-151-4/+8
* Fix typoJames Booth2016-10-291-1/+1
* Add win_printJames Booth2016-10-151-1/+1
* Use win_printf_line instead of win_printlnJames Booth2016-10-151-1/+1
* Add sv_ev_bookmark_autojoinJames Booth2016-08-281-0/+22
* Free rooms list in sv_ev_login_account_successJames Booth2016-07-251-2/+3
* Tidy headersJames Booth2016-07-241-6/+7
* Moved window_list.cJames Booth2016-07-241-1/+1
* Moved roster_list.cJames Booth2016-07-241-1/+1
* Moved muc.cJames Booth2016-07-241-1/+1
* Moved chat_session.cJames Booth2016-07-241-1/+1
* Update GPL link in headersJames Booth2016-07-241-1/+1
* Option to bookmark room invitesJames Booth2016-05-231-1/+7
* Remove redundant tls secured functionJames Booth2016-05-061-1/+1
* Move connection fulljid functionJames Booth2016-05-061-2/+2
* Rename jabber_ functionsJames Booth2016-05-061-3/+3
* Define stanza's attributes as const char*Dmitry Podgorny2016-04-271-1/+1
* Free mentions listJames Booth2016-04-071-0/+2
* Added whole word matches for room mentionJames Booth2016-04-071-4/+12
* Added mention match preferencesJames Booth2016-04-031-4/+2
* Added prof_strstr functionJames Booth2016-04-031-9/+5
* Removed #AX_PREFIX_CONFIG_HJames Booth2016-03-311-22/+22
* Added plugins presence hooksJames Booth2016-03-301-0/+3
* Update roster count on carbonsJames Booth2016-03-221-0/+1
on' href='/gbmor/getwtxt/blame/main.go?h=v0.1&id=d62c82f30506baa430fb7e3e117f007cfa66ac13'>^
893123c ^
bd5e602 ^
c87acad ^



bd5e602 ^
c87acad ^
893123c ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


            
             

                  
              

                                     
                                

 

                     
             
 


                                                        
                                                  

                                                   
                         


                                         


                                       


                                           

                                                          


                                             

                                                                      
                                                                             
                               



                                                                             
                                                        
                               
                                               
                                           
                                                         
                                                                               
                                
                                                   
                                 


                                               
                                              


                                                                 
 
                                                     
                                                   


                                                        

                                                              
                                      


                                               
 
                                                          



                                       
 
                        
 
package main

import (
	"fmt"
	"log"
	"net/http"
	"time"

	"github.com/gorilla/handlers"
	"github.com/gorilla/mux"
)

const getwtxt = "0.1"

func main() {

	// StrictSlash(true) allows /api and /api/
	// to serve the same content without duplicating
	// handlers/paths
	index := mux.NewRouter().StrictSlash(true)
	api := index.PathPrefix("/api").Subrouter()

	// <3 gorilla/mux
	index.Path("/").
		Methods("GET").
		HandlerFunc(indexHandler)
	index.Path("/css").
		Methods("GET").
		HandlerFunc(cssHandler)
	index.Path("/api").
		Methods("GET").
		HandlerFunc(apiBaseHandler)
	// twtxt will add support for other formats later.
	// Maybe json? Making this future-proof.
	api.Path("/{format:(?:plain)}").
		Methods("GET").
		HandlerFunc(apiFormatHandler)
	// Specifying the endpoint with and without query information.
	// Will return 404 on empty queries otherwise.
	api.Path("/{format:(?:plain)}/{endpoint:(?:mentions|users|tweets)}").
		Methods("GET").
		HandlerFunc(apiEndpointHandler)
	// Using stdlib net/url to validate the input URLs rather than regex.
	// Validating a URL with regex is unwieldly
	api.Path("/{format:(?:plain)}/{endpoint:(?:mentions|users|tweets)}").
		Queries("url", "{url}", "q", "{query}").
		Methods("GET").
		HandlerFunc(apiEndpointHandler)
	// This is for submitting new users
	api.Path("/{format:(?:plain)}/{endpoint:users}").
		Queries("url", "{url}", "nickname", "{nickname:[a-zA-Z0-9]+}").
		Methods("POST").
		HandlerFunc(apiEndpointPOSTHandler)
	// Show all observed tags
	api.Path("/{format:(?:plain)}/tags").
		Methods("GET").
		HandlerFunc(apiTagsBaseHandler)
	// Requests tweets with a specific tag
	api.Path("/{format:(?:plain)}/tags/{tags:[a-zA-Z0-9]+}").
		Methods("GET").
		HandlerFunc(apiTagsHandler)

	// format the port for the http.Server object
	portnum := fmt.Sprintf(":%v", confObj.port)
	// defines options for the http server.
	// handlers.CompressHandler gzips all responses.
	// Write/Read timeouts are self explanatory.
	server := &http.Server{
		Handler:      handlers.CompressHandler(index),
		Addr:         portnum,
		WriteTimeout: 15 * time.Second,
		ReadTimeout:  15 * time.Second,
	}

	log.Printf("Listening on port %v\n", confObj.port)
	err := server.ListenAndServe()
	if err != nil {
		log.Printf("%v\n", err)
	}

	closelog <- true
}